<driver>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver>
<serverURL>jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=abc</serverURL>
<serverURL>jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=abc</serverURL>
解决方案 »
- 登陆界面 代码急急急...........
- 奇怪,System.getProperty("user.dir"),tomcat下获得的居然是logs目录???
- hibernate异常?
- 小小小小小小小小小小小小-----的--非技术性--问题
- 怎么解决面试中算法题目~~~~~~~~
- 请教一个典型的struts和hibernate结合查询数据库的技术问题,帮帮我,谢谢你.
- 这个异常怎么解决啊?望高手指教!
- 不会用STRUTS标签,大家来帮我看看.
- 请教 RosettaNet 和 cbXML 问题,我最近在做 weblogic 和 websphere 之间的 B2B
- About Jcreator?
- ▽▽▽谁有Weblogic Server 7.0或(8.1)软件,帮帮忙!给我发一个!!!▽▽▽
- 哪里有SQL Server 2000 JDBC驱动程序的帮助文档?
jdbc:microsoft:sqlserver://127.0.0.1:1433,name,password
或者
sun.jdbc.odbc.SQLServerDriver
jdbc:odbc:DataSourceName
你可以到其网站上下载。Driver for JDBC installation directory: install_dir/lib/msbase.jar
install_dir/lib/msutil.jar
install_dir/lib/mssqlserver.jar Windows Example
//将安装路径注册
CLASSPATH=.;c:\Microsoft SQL Server 2000 Driver for JDBC\lib\msbase.jar;c:\Microsoft SQL Server 2000 Driver for JDBC\lib\msutil.jar;c:\Microsoft SQL Server 2000 Driver for JDBC
\lib\mssqlserver.jar UNIX Example
CLASSPATH=.;/home/user1/mssqlserver2000jdbc/lib/msbase.jar;/home/user1/mssqlserver2000jdbc/lib/msutil.jar;/home/user1/mssqlserver2000jdbc/lib/mssqlserver.jar 2. Registering the Driver
Registering the driver tells the JDBC driver manager which driver to load. When loading a driver using class.forName(), you must specify the name of the driver: com.microsoft.jdbc.sqlserver.SQLServerDriver For example:
在联接之前必须调用这一句Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); 3. Passing the Connection URL
After registering the driver, you must pass your database connection information in the form of a connection URL. The following is a template URL for the SQL Server 2000 Driver for JDBC. Substitute the values specific to your database. (For instructions on connecting to named instances, see "Connecting to Named Instances" in the SQL Server 2000 Driver for JDBC topic.) jdbc:microsoft:sqlserver://server_name:1433 For example, to specify a connection URL that includes the user ID "username" and the password "secret": Connection conn = DriverManager.getConnection
("jdbc:microsoft:sqlserver://server1:1433","username","secret"); 注意:url 可以是一个串,
"jdbc:microsoft:sqlserver://server_name(or IP address):1433,User=username,Password=password"NOTES: The server_name is an IP address or a host name, assuming that your network resolves host names to IP addresses. You can test this by using the ping command to access the host name and verifying that you receive a reply with the correct IP address.
<serverURL>jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=abc</serverURL>
的可以,我使用 jdatasource 连接成功了
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@localhost:1521:orcl";
//orcl为数据库的SID
String user="test";
String password="test";
Connection conn= DriverManager.getConnection(url,user,password); 2、DB2数据库
Class.forName("com.ibm.db2.jdbc.app.DB2Driver ").newInstance();
String url="jdbc:db2://localhost:5000/sample";
//sample为你的数据库名
String user="admin";
String password="";
Connection conn= DriverManager.getConnection(url,user,password); 3、Sql Server7.0/2000数据库
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=mydb";
//mydb为数据库
String user="sa";
String password="";
Connection conn= DriverManager.getConnection(url,user,password); 4、Sybase数据库
Class.forName("com.sybase.jdbc.SybDriver").newInstance();
String url =" jdbc:sybase:Tds:localhost:5007/myDB";
//myDB为你的数据库名
Properties sysProps = System.getProperties();
SysProps.put("user","userid");
SysProps.put("password","user_password");
Connection conn= DriverManager.getConnection(url, SysProps); 5、Informix数据库
Class.forName("com.informix.jdbc.IfxDriver").newInstance();
String url =
"jdbc:informix-sqli://123.45.67.89:1533/myDB:INFORMIXSERVER=myserver;
user=testuser;password=testpassword";
//myDB为数据库名
Connection conn= DriverManager.getConnection(url); 6、MySQL数据库
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url ="jdbc:mysql://localhost/myDB?user=soft&password=soft1234&useUnicode=true&characterEncoding=8859_1"
//myDB为数据库名
Connection conn= DriverManager.getConnection(url); 7、PostgreSQL数据库
Class.forName("org.postgresql.Driver").newInstance();
String url ="jdbc:postgresql://localhost/myDB"
//myDB为数据库名
String user="myuser";
String password="mypassword";
Connection conn= DriverManager.getConnection(url,user,password);
JDBC URL 中的协议总是 jdbc。
<子协议> ─ 驱动程序名或数据库连接机制(这种机制可由一个或多个驱动程序支持)的名称。子协议名的典型示例是 "odbc",该名称是为用于指定 ODBC 风格的数据资源名称的 URL 专门保留的。例如,为了通过JDBC-ODBC 桥来访问某个数据库,可以用如下所示的 URL:jdbc:odbc:fred本例中,子协议为 "odbc",子名称 "fred" 是本地ODBC 数据资源。
代码同上几位~~