| 
| 
查看: 1188|回复: 5
 | 
JSP : 如何connect去SQL Server
[复制链接] |  
 |  | 
 
| 我现在是用JRUN 来跑 jsp的,connect去MS SQL Server 2000的coding如下: 
 <%!
 static final String DBDriver  ="macromedia.jdbc.MacromediaDriver";
 static final String DBConn  ="jdbc:macromedia:sqlserver://localhost:1433;DatabaseName=project;SelectMethod=cursor";
 
 Connection Conn;
 String TempString="";
 
 %>
 
 <%
 try{
 //Create Database Connection
 Class.forName(DBDriver).newInstance();
 Conn = DriverManager.getConnection(DBConn,"sa", "password");
 }
 catch(Exception e){TempString = "SQL Exception";}
 %>
 
 现在我想用TOMCAT 来run我的system,结果connect不到 SQL Server了。
 请问要写怎样的connection才可以用Tomcat connect到SQL Server 呢?
 我尝试用这个也不行呢。。
 static final String DBDriver  ="com.microsoft.jdbc.sqlserver.SQLServerDriver";
 static final String DBConn   ="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=project;SelectMethod=cursor";
 
 谢谢~
 | 
 |  |  |  |
 
|  |  |  
|  |  | 
 |  | 
 
 发表于 18-11-2005 06:19 PM
|
显示全部楼层 |  |  |  |
 
|  |  |  
|  |  | 
 |  | 
 
 
 楼主|
发表于 18-11-2005 10:42 PM
|
显示全部楼层 
| 原帖由 ww2020 于 18-11-2005 06:19 PM 发表我的tomcat用这个
 Class.forName("com.mysql.jdbc.Driver").newInstance();
 sqlCon = java.sql.DriverManager.getConnection("jdbc:mysql://localhost/mysql","root","&quo ...
 
 在coding前需要弄什么setting吗?如在Control Panel的administrative tool里加东西呢?
 
 [ 本帖最后由 winterain 于 18-11-2005 10:45 PM 编辑 ]
 | 
 |  |  |  |
 
|  |  |  
|  |  | 
 |  | 
 
 
 楼主|
发表于 19-11-2005 08:01 PM
|
显示全部楼层 
| 没有人知道吗?我要交FINAL PROJECT了噢, 里面要写installation guide~不知道要如何用TOMCAT来跑我的system,因为要connect去 MS SQL SERVER~
 | 
 |  |  |  |
 
|  |  |  
|  |  | 
 |  | 
 
 发表于 21-11-2005 10:57 AM
|
显示全部楼层 
| 需要Download mysql-connector.jar, 放到JAVA的lib Folder | 
 |  |  |  |
 
|  |  |  
|  |  | 
 |  | 
 
 发表于 22-11-2005 10:56 AM
|
显示全部楼层 
| 需要把 DATABASE DRIVER 的 jar FILE , 放到 TOMCAT 的lib Folder。。。 | 
 |  |  |  |
 
|  |  |  
|  |  |  |  | 
            本周最热论坛帖子 |