Topic: SQLServer JDBC 驱动程序的问题 |
Print this page |
1.SQLServer JDBC 驱动程序的问题 | Copy to clipboard |
Posted by: Henry2006 Posted on: 2007-10-03 18:35 代码如下: import java.sql.*; public class DBConnection { private final String DBDRIVER = "com.microsoft.jdbc.sqlserver.SQLServerDriver" ; private final String DBURL = "jdbc:microsoft:sqlserver://127.0.0.1:1433" ; private final String DBUSER = "sa" ; private final String DBPASSWORD = "" ; private Connection conn = null ; public DBConnection() { try { Class.forName(DBDRIVER) ; this.conn = DriverManager.getConnection(DBURL,DBUSER,DBPASSWORD) ; } catch (Exception e) { e.printStackTrace() ; } } public Connection getConnection() { return this.conn ; } public void close() { try { this.conn.close() ; } catch (Exception e) { e.printStackTrace() ; } } }; 写一个启动运行类,没问题可以连接但是,DAO模式中会把这些搞成一个 工具类,在调用工具类的时候好像是说加载驱动程序错误。 |
2.Re:SQLServer JDBC 驱动程序的问题 [Re: Henry2006] | Copy to clipboard |
Posted by: Henry2006 Posted on: 2007-10-03 19:39 问题已解决,是classpath的问题。 |
3.Re:SQLServer JDBC 驱动程序的问题 [Re: Henry2006] | Copy to clipboard |
Posted by: wxpsjm Posted on: 2007-10-28 14:50 看一下你的*.jar。。有没有问题。。重新导入一下。。 要是不行。。就用连接池吧。。安全。。速度又快 |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |