Best unofficial Apache Server developers community
Username
Forgot password?
Sign in with Twitter account
Sign in with Facebook account

JDBC Driver in OSGI (Eclipse IDE)

0

140 views

Hi, I am having some problems with getting my OSGI programs to recognzie/utilize the mysql jdbc driver.

I have a bundle that is speficcally for entering data into a mysql database. I have copied over all the same methods as in a test program (non-OSGI). I am not able to create a connection suing DriverManager.getConnection().

I have added the driver to the class path andhave tried all the solutions on this site such as using Class.forName(). Possibly I am inputting the wrong string arg into forName().

public void createConn(String URL, String DBName, String username, String password){

 try {
   Class.forName("mysql-connector-java-5.1.14-bin.jar");
  } catch (ClassNotFoundException e1) {
   e1.printStackTrace();
  }
  try {
   conn = DriverManager.getConnection(URL + DBName,username,password);
   System.out.println("Connection Created");
   stmt = conn.createStatement();
   System.out.println("Statement Created");
   //data = new ApplianceData();

   //flag = true;
   //this.writeThread = new Thread();
   //writeThread.start();

  } catch (SQLException e) {
   System.err.println(e.getMessage());
  }
}

  • Can someone tell me the argument they used in Class.forName();

  • Does anybody have a solution to this problem or encountered this?

asked January 27, 2011 3:37 pm CST
posted via StackOverflow

1 Answers

0
 

Class.forName(String) takes a fully qualified class name, not a jar file. You should use something like

Class.forName("com.mysql.jdbc.Driver");

answered January 28, 2011 6:32 am CST

Your answer

Join with account you already have


Sign in with Twitter account
Sign in with Facebook account
Sign in with Google Friend Connect

Preview
Similar questions
QT QPSQL driver problem
December 28, 2010
General JDBC Setup
January 6, 2011