[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [ajug-members]: DataSource / DriverManager
I think you'll find the datasource more user-friendly once you get used to
it.
Import java.sql.*;
Import javax.sql.*;
com.mysql.jdbc.jdbc2.optional.MysqlDataSource
.....
MysqlDataSource mds = new MysqlDataSource();
mds.setURL("jdbc:mysql://host:port/db");
mds.setUser("user");
mds.setPassword("password");
//Use generic datasource interface instead of vendor-specific
DataSource ds = (DataSource)mds;
//get the connection
Connection conn = ds.getConnection();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("Select * from foo");
-----Original Message-----
From: David Black [mailto:DavidBlack@Cobol-Conversions.com]
Sent: Tuesday, April 20, 2004 11:39 AM
To: Unlisted-recipients
Subject: [ajug-members]: DataSource / DriverManager
I have been writing J2ME code for the Sharp Zaurus handheld. In the
past they used the DriverManager Model for connecting to the DataBase.
In the new Zaurus 6000 they use the DataSource model of using JDBC. I
use a simple class to make all the connections now. I need to change
my connection process.
Does any one have a simple example of connecting to a database using the
DataSource model?
Thanks for any ideas.
David Black