John Smith John Smith - 3 years ago 156
Apache Configuration Question

jdbc connector for Apache Olingo

I have developed a JAVA Project using Apache Olingo in which i am trying to fetch data from MySQL Database but I am getting following error

Got an exception!

Which library is to be import for this in Apache olingo. Below is my Java Class

private EntityCollection getData(EdmEntitySet edmEntitySet){

EntityCollection productsCollection = new EntityCollection();
// check for which EdmEntitySet the data is requested
if(DemoEdmProvider.ES_PRODUCTS_NAME.equals(edmEntitySet.getName())) {
List<> productList = productsCollection.getEntities();

// create our mysql database connection
//String myDriver = "";
String myDriver ="com.mysql.jdbc.Driver";
String myUrl = "jdbc:mysql://localhost:3306/testDB";
Connection conn = DriverManager.getConnection(myUrl, "root", "test1234");

// our SQL SELECT query.
// if you only need a few columns, specify them by name instead of using "*"
String query = "SELECT * FROM Employee";

// create the java statement
Statement st = conn.createStatement();

// execute the query, and get a java resultset
ResultSet rs = st.executeQuery(query);

// iterate through the java resultset
while (

String NAME = rs.getString("NAME");
String CITY = rs.getString("CITY");
int AGE = rs.getInt("AGE");

// print the results
final Entity e1 = new Entity()
.addProperty(new Property(null, "NAME", ValueType.PRIMITIVE, NAME))
.addProperty(new Property(null, "CITY", ValueType.PRIMITIVE, CITY))
.addProperty(new Property(null, "AGE", ValueType.PRIMITIVE,
e1.setId(createId("Products", 1));
catch (Exception e)
System.err.println("Got an exception! ");

Answer Source

You can Add mysql connector Jar File link are:

download and to import your project--> right click-->import -->File System -->Browse-->where are you store your connector

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download