首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

jsp与sql2000连接的有关问题!待

2013-09-11 
jsp与sql2000连接的问题!在线等待错误如下,tomcat的lib里面已经放了那三个jar文件,我的是xpsql2000sp3的补

jsp与sql2000连接的问题!在线等待
错误如下,tomcat的lib里面已经放了那三个jar文件
,我的是xp   sql2000     sp3的补丁打不上,说什么指定的实例名无效     我应该怎么做?急死了!
type   Exception   report

message  

description   The   server   encountered   an   internal   error   ()   that   prevented   it   from   fulfilling   this   request.

exception  

org.apache.jasper.JasperException:   Exception   in   JSP:   /test.jsp:10

7:        
8:       String       user= "sa ";          
9:       String       password= "sa ";          
10:       Connection       conn=       DriverManager.getConnection(url,user,password);          
11:       Statement       stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);          
12:       String       sql= "select       *       from       jobs ";          
13:       ResultSet       rs=stmt.executeQuery(sql);          


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:506)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root   cause  

javax.servlet.ServletException:   [Microsoft][SQLServer   2000   Driver   for   JDBC]Error   establishing   socket.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:843)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:776)
org.apache.jsp.test_jsp._jspService(test_jsp.java:84)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root   cause  

java.sql.SQLException:   [Microsoft][SQLServer   2000   Driver   for   JDBC]Error   establishing   socket.
com.microsoft.jdbc.base.BaseExceptions.createException(Unknown   Source)
com.microsoft.jdbc.base.BaseExceptions.getException(Unknown   Source)
com.microsoft.jdbc.base.BaseExceptions.getException(Unknown   Source)
com.microsoft.jdbc.sqlserver.tds.TDSConnection. <init> (Unknown   Source)
com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown   Source)
com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown   Source)
com.microsoft.jdbc.base.BaseConnection.open(Unknown   Source)
com.microsoft.jdbc.base.BaseDriver.connect(Unknown   Source)
java.sql.DriverManager.getConnection(Unknown   Source)
java.sql.DriverManager.getConnection(Unknown   Source)
org.apache.jsp.test_jsp._jspService(test_jsp.java:53)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)


javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note   The   full   stack   trace   of   the   root   cause   is   available   in   the   Apache   Tomcat/5.5.20   logs.



[解决办法]
没升级呵
[解决办法]
package helloWorld;

import javax.servlet.*;
import javax.servlet.http.*;

import java.io.*;
import java.util.*;
import java.sql.*;

public class TestConnSql
extends HttpServlet {
private static final String CONTENT_TYPE = "text/html; charset=GB18030 ";

//Initialize global variables
public void init() throws ServletException {
}


public void doPost() throws
ServletException, IOException {

String bookname= "hhe ";
String bookauthor= "wooo ";
String bookprice= "65 ";
String bookintroduce= "dfdasdfasdfas ";
try
{
Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver ").newInstance();
Connection conn = DriverManager.getConnection( "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=bbs ", "sa ", "19840309 ");
Statement st=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String update_cmd= "insert into [bookINfo] values( ' "+bookname+ " ', ' "+bookauthor+ " ', ' "+bookprice+ " ', ' "+bookintroduce+ " ') ";
System.out.println(update_cmd);
st.executeUpdate(update_cmd);
System.out.println( "CONN is OK! ");

conn.close();

}
catch(Exception e)
{
e.printStackTrace();
}

}

//Clean up resources
public void destroy() {
}

public static void main(String arg[]){
TestConnSql test=new TestConnSql();
try{
test.doPost();
}catch (Exception e){
e.printStackTrace();
}
}
}


[解决办法]
用ODBC数据源
[解决办法]
对于数据库连接,需要作如下测试:
1,ping 数据库服务器,首先保证 能够连通
2,telnet 数据库服务器 1433
测试数据库服务器是否在1433端口监听,因为只有已经在1433端口监听的数据库,才能够通过上述方式连接。
[解决办法]
方法一

import java.io.PrintStream;
import java.sql.*;

public class dbbean{

Connection conn;
ResultSet rs;
String dataSource;
String url;
String user;
String passwd;
public dbbean() {
conn = null;
rs = null;
dataSource = "cpasm ";
url = "jdbc:microsoft:sqlserver://10.161.18.68:1433 ";
user = "sa ";
passwd = "123456 ";
}
public int ConnectDb(String s, String s1, String s2){
try{
conn = DriverManager.getConnection(s, s1, s2);
}catch(SQLException sqlexception){
System.out.println( "\u57F7\u884CSqlServer\u8A9E\u53E5\u5931\u6557 " + sqlexception.getMessage());


return -1;
}
return 0;
}
public ResultSet executeQuery(String s){
try{
Statement statement = conn.createStatement();
rs = statement.executeQuery(s);
}catch(SQLException sqlexception){
System.err.println( "sqlbean.executeQuery: " + sqlexception.getMessage());
}
return rs;
}

public boolean execute(String s){
boolean flag = false;
try{
Statement statement = conn.createStatement();
statement.execute(s);
flag = true;
}catch(SQLException sqlexception){
System.err.println( "sqlbean.executeQuery: " + sqlexception.getMessage());
}
return flag;
}
}
方法二
import java.io.PrintStream;
import java.sql.*;

public class cencon
{

String sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver ";
String sConnStr = "jdbc:odbc:cencon ";//cencon數據源
Connection conn = null;
ResultSet rs = null;

public cencon(){
try {
Class.forName(sDBDriver);
}
catch(java.lang.ClassNotFoundException e)
{
System.err.println(e.getMessage());
}
}
public ResultSet executeQuery(String sql)
{
rs = null;
try {
conn = DriverManager.getConnection(sConnStr, "用戶 ", "密碼 ");
Statement stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
}
catch(SQLException ex)
{
System.err.println(ex.getMessage());
}
return rs;
}
}
[解决办法]
你没有打上补丁sp4,打完补丁后就会发现在C盘有一个这样的文件SQL2KSP4下有一个setup.bat文件,你再双击它再安装,,应该就可以了...
[解决办法]
女上司对我特别照顾,可我是个结过婚的人,我该怎么办?

http://community.csdn.net/Expert/topic/5515/5515498.xml?temp=.4312403
[解决办法]
打sp3补丁!
JDBC的补丁和
SQL sever的补丁都要打
打过补丁就好了!
这个问题太常见了!
[解决办法]
把JDBC的三个文件,放到JDK的运行时目录中就行了。
[解决办法]
是数据库的问题,直接打SP4补丁,用你查询分析器的用户和密码,你现在用sa,sa不知能否登录?
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html

热点排行