您的位置:首页 > 编程语言 > Java开发

java连接池使用方法二

2004-12-01 23:40 696 查看
使用方法:
  连接sqlserver:
  Class.forName("net.sourceforge.jtds.jdbc.Driver").newInstance();
   String url ="jdbc:jtds:sqlserver://localhost:1433/check";//check是数据库名
   cnn = DriverManager.getConnection(url, user, password);

它的帮助 是这样写的:
driver:net.sourceforge.jtds.jdbc.Driver
url:
The URL format for jTDS is:
    jdbc:jtds:<server_type>://<server>[:<port>][/<database>][;<property>=<value>[;...]]
where <server_type> is one of either 'sqlserver' or 'sybase' (their meaning is quite obvious), <port> is the port the database server is listening to (default is 1433 for SQL Server and 7100 for Sybase) and <database> is the database name -- JDBC term: catalog -- (if not specified, the user's default database is used). The set of properties supported by jTDS is:

user (required)
User name to use for login. When using getConnection(String url, String user, String password) it's not required to set this property as it is passed as parameter, but you will have to set it when using getConnection(String url, Properties info) or TdsDataSource.
password (required)
Password to use for login. When using getConnection(String url, String user, String password) it's not required to set this property as it is passed as parameter, but you will have to set it when using getConnection(String url, Properties info) or TdsDataSource.
这是用于sybase或者sqlserver的,其它数据库你还要看它的文档

-------------------------------------------------------------------------------------
文章地址:http://community.csdn.net/Expert/topic/3589/3589555.xml?temp=.952572
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息