佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 1117|回复: 5

JSP : 如何connect去SQL Server

[复制链接]
发表于 18-11-2005 04:20 PM | 显示全部楼层 |阅读模式
我现在是用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";

谢谢~
回复

使用道具 举报


ADVERTISEMENT

发表于 18-11-2005 06:19 PM | 显示全部楼层
我的tomcat用这个
Class.forName("com.mysql.jdbc.Driver".newInstance();
sqlCon = java.sql.DriverManager.getConnection("jdbc:mysql://localhost/mysql","root","";

我是mysql...

[ 本帖最后由 ww2020 于 18-11-2005 06:22 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。。。
回复

使用道具 举报

Follow Us
您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 3-3-2025 10:54 PM , Processed in 0.128408 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表