I'm doing as a school project a multi-platform Distributed Data Base System
I need to extract data from the Data Base in Java so i dynamically load my jdbc connector
Works Perfect in Windows
But in Linux I got the error:
"No suitable driver found for jdbc:mysql://..."
This is the code:
File f = new File("mysql-connector-java-5.1.24-bin.jar");
URLClassLoader urlCl = new URLClassLoader(new URL[] { f.toURL()},System.class.getClassLoader());
Class conector = urlCl.loadClass("com.mysql.jdbc.Driver");
conector.newInstance();
Connection conexion = DriverManager.getConnection("jdbc:mysql://localhost/test","root","");
Statement instruccion = conexion.createStatement();
ResultSet tabla = instruccion.executeQuery("select * from prueba where uno=1");
while(tabla.next())
{
System.out.println(tabla.getString(1));
System.out.println(tabla.getString(2));
}
conexion.close();
I don't know what can I do.
This it's made to avoid the installation of the connector on each site
I pass a file with the configuration for each DB, if is postgresql load postgres jdbc conector if is mysql etc...
Suggestions?