JAP连接数据库问题

来源:百度知道 编辑:UC知道 时间:2024/05/15 15:38:50
请问Jsp如何连接AQLserver啊?我做的程序怎么都连接不上,报错是
Generated servlet error:
[javac] Since fork is true, ignoring compiler setting.
[javac] Compiling 1 source file
[javac] Since fork is true, ignoring compiler setting.
[javac] C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\bbs\default_jsp.java:100: rs is already defined in _jspService(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
[javac] ResultSet rs=stmt.executeQuery(sql);
[javac] ^
[javac] 1 error

我想是我的连接文件写错了,下面是我的conn.jsp
<%@ page import="java.sql.*" %>
<%@ page import="javax.naming.*"%>
<%@ page import="javax.sql.*"%>
<%
java.sql.Connection conn;
java.sql.Statement stmt;
java.sql.ResultSet rs;

Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver&qu

5. Microsoft SQLServer(http://jtds.sourceforge.net)
Class.forName( "net.sourceforge.jtds.jdbc.Driver" );
cn = DriverManager.getConnection( "jdbc:jtds:sqlserver://MyDbComputerNameOrIP:1433/master", sUsr, sPwd );

6. Microsoft SQLServer(http://www.microsoft.com)
Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver" );
cn = DriverManager.getConnection( "jdbc:microsoft:sqlserver://MyDbComputerNameOrIP:1433;databaseName=master", sUsr, sPwd );
这是我总结的两种SQLServer连接数据库的语法,你试试