Re: Anything wrong?
On 4月17日, 上午12时50分, "Peter H. Coffin" <hell...@ninehells.com> wrote:
> On Wed, 16 Apr 2008 09:07:27 -0700 (PDT), 525 wrote:
> > Is there anything wrong as follow method to use DdriverManager to get
> > connection in mysql with j2ee?
>
> > public class DBHandle {
>
> > public synchronized static Connection getConn() throws Exception {
> > Connection conn = null;
> > DataSource ds = null;
> > Context ctx = new InitialContext();
> > ds = (DataSource) ctx.lookup("java:comp/env/jdbc/stat");
> > if (ds != null) {
> > conn = ds.getConnection();
> > }
> > return conn;
> > }
>
> > public static void closeResource(Statement st, ResultSet rs,
> > Connection cnn) {
> > ...........
> > }
>
> > public static Connection getConnection() throws Exception {
> > String driver = "com.mysql.jdbc.Driver";
> > String urlString = "jdbc:mysql://localhost/stat";
> > String user = "root";
> > String pwd = "root";
> > Class.forName(driver);
> > Connection cnn = DriverManager.getConnection(urlString, user,
> > pwd);
> > return cnn;
> > }
>
> > }
>
> I dunno. What did you expect that it would do? What actually happened?
>
> --
> Christian Biblical literalists are trusting themselves to an archaic English
> translation of a Latin translation of (help me here) Greek? Aramaic? source.
> I wouldn't even trust a VCR manual to make it through that intact. - Dr. Dee- 隐藏被引用文字 -
>
> - 显示引用的文字 -
can the mysql connector/j 5.0 match with mysql
5.0.18,tomcat5.5.25,jdk1.5.?
also,what 's the different bewteen "org.gjt.mm.mysql.Driver" and
"com.mysql.jdbc.Driver"? thus the code above " String driver =
"com.mysql.jdbc.Driver"; " right?
|