drizzle
Profile
Search
 
Powered by SoftLayer
JDBC/GettingStarted

Getting started with JDBC

Here is an example of how to connect to a drizzle server and execute a query:

Connection  connection = DriverManager.getConnection("jdbc:drizzle://localhost:4427/test_units_jdbc");
Statement stmt = connection.createStatement();
stmt.executeUpdate("CREATE TABLE a (id int not null primary key, value varchar(20))");
stmt.close();
connection.close();

And here is an example of how to connect to a MySQL server:

Connection  connection = DriverManager.getConnection("jdbc:mysql:thin://username:password@localhost:3306/test_units_jdbc");
Statement stmt = connection.createStatement();
stmt.executeUpdate("CREATE TABLE a (id int not null primary key, value varchar(20))");
stmt.close();
connection.close();

Note that you must use new passwords and MySQL 4.1+ to use drizzle-jdbc with MySQL - i.e. no old_passwords=1 in your my.cnf (default in fedora)

Site generously hosted by SoftLayer Technologies