|
Hi !
Very easy ! Just get a JDBC-Driver (e.g. from
http://www.worldserver.com/mm.mysql/) and do the following:
/*
* Register the driver using Class.forName() */ Class.forName("org.gjt.mm.mysql.Driver").newInstance() /* * Register the driver via the system properties variable * "jdbc.drivers"
*/
Properties P = System.getProperties(); P.put("jdbc.drivers", "org.gjt.mm.mysql.Driver"); System.setProperties(P); Connection Conn = null; try {
Conn = DriverManager.getConnection("jdbc:mysql://hostname:port/db?user=name&password=secret");
}
catch (Exception E) {
System.out.println("Connection failed : " + E.getMessage());
throw E;
}
// The URL string for the getConnection() method has the following format: // jdbc:mysql://hostname[:port]/database[?extra_param1=value][&extra_param2=value] // After you have a connection you can create a Statement and execute simple queries: Bye bye Christian Schulz
|
- AW: Apache and MySql Christian Schulz
- AW: Apache and MySql Czichos, Marc
