<%@ page contentType="text/html; charset=gb2312" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head><LINK href="hellking.css" type=text/css rel=stylesheet>
<body>
<%
boolean isLog=false;
// out.println(session.getAttribute("isLog"));
try
{
isLog=((String)session.getAttribute("isLog")).equals("1");
}
catch(Exception e)
{
//out.println(e);
}
%>
<table width="842" align=center cellpadding=3 cellspacing=1 class=tableborder1>
<tr>
<td width="832" class=tablebody2>锛氾細
<a href="index.jsp" target="_top">棣栭〉</a>
<a href="index.jsp" target="_top">閭欢</a>
<a href="shop/searchForm.html" target="mainFrame">鍟嗗搧鎼滅储</a>
<a href="/jspdev/servlet/forumservlet?jumpPage=1" target="mainFrame">璁哄潧</a>
<%
if(isLog)
{
if(((Integer)session.getAttribute("userType")).equals(new Integer(1)))
{
%>
<a href="index.jsp" target="_top">涓汉淇℃伅</a>
<%}
else
{
%>
<a href="manage/index.jsp" target="_new">绯荤粺绠$悊</a>
<%
}
%>
<a href="logout.jsp" target="_top">娉ㄩ攢</a><%}%>锛氾細
</td> </tr> <tr>
<td width="832" class=tablebody2>
<%
// out.println(isLog);
if(isLog)
{
%>
娆㈣繋鍏変复锛?lt;%=session.getAttribute("name")%>,鎮ㄦ槸绗?lt;%=session.getAttribute
("userLogCount")%>娆$櫥褰曪紝鎮ㄤ笂娆$櫥褰曠殑鏃堕棿鏄細<%=session.getAttribute("userLastLogTime")%>
<%
}//if
else
{
%>
<form name="form1" method="post" action="login.jsp">
鐢ㄦ埛鍚?nbsp;
<input type="text" name="userId" size="15" style="BORDER-RIGHT: #ffffff 1px groove;
BORDER-TOP: #ffffff 1px groove; FONT: 12px Verdana,Geneva,sans-serif; BORDER-LEFT: #ffffff
1px groove; WIDTH: 100px; COLOR: #000000; BORDER-BOTTOM: #ffffff 1px groove; HEIGHT: 18px;
BACKGROUND-COLOR: #DFF1F9">
瀵嗙爜
<input type="password" name="password" size="15" style="BORDER-RIGHT: #ffffff 1px
groove; BORDER-TOP: #ffffff 1px groove; FONT: 12px Verdana,Geneva,sans-serif; BORDER-LEFT:
#ffffff 1px groove; WIDTH: 100px; COLOR: #000000; BORDER-BOTTOM: #ffffff 1px groove; HEIGHT:
18px; BACKGROUND-COLOR: #DFF1F9">
<input type="submit" name="Submit" value="纭畾" style="height:20; font:9pt; BORDER-
BOTTOM: #cccccc 1px groove; BORDER-RIGHT: #cccccc 1px groove; BACKGROUND-COLOR: #eeeeee">
</form>
<%
}//else
%>
</td>
</tr>
</table>
</body>
</html>
login.jsp浠g爜濡備笅锛?
<%@ include file="include.inc"%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<%
//鑾峰緱璇锋眰鐨勫弬鏁般€?
String id=request.getParameter("userId");
String psw=request.getParameter("password");
//杩炴帴鏁版嵁搴?
Class.forName(CLASSFORNAME);
Connection con = DriverManager.getConnection(SERVANDDB,USER,PWD);
Statement statement=con.createStatement();
String isCorrect="select * from user_info where userId='" + id + "' and password='" + psw +
"'";
ResultSet result=statement.executeQuery(isCorrect);
session.setAttribute("isLog",new String("0"));
if(!result.next())
{
response.sendRedirect("index.jsp");//璐﹀彿鎴栧瘑鐮侀敊璇紝杞叆閿欒椤甸潰
result.close();
statement.close();
con.close();
}
//濡傛灉鏌ヨ鍚庢湁璁板綍锛岃鏄庣櫥褰曢獙璇佹垚鍔熴€?
else
{
//淇濆瓨鐧诲綍淇℃伅鍒皊ession瀵硅薄涓€?
session.setAttribute("name",result.getString("name"));
session.setAttribute("id",result.getString("userId"));
session.setAttribute("email",result.getString("email"));
session.setAttribute("fav",result.getString("fanvcategory"));
session.setAttribute("userType",new Integer(result.getInt("userType")));
System.out.println(session.getAttribute("userType"));
session.setAttribute("isLog",new String("1"));
int count=result.getInt("userLogCount");
session.setAttribute("userLogCount",new Integer(count));
count++;
session.setAttribute("userLastLogTime",result.getString("userLastLogTime"));
java.util.Date time1=new java.util.Date();//鑾峰緱绯荤粺褰撳墠鏃堕棿
String sqltime=new Timestamp(time1.getTime()).toString();//灏嗗綋鍓嶆椂闂磋浆鎹㈡垚sql server
鍙互璇嗗埆鐨勫璞?nbsp;
//鏇存柊鐧诲綍淇℃伅銆?
statement.execute("update user_info set
userLogCount="+count+",userLastLogTime='"+sqltime+"' where userId='" + id +"'");
//鍏抽棴鏁版嵁搴撹繛鎺ョ浉鍏崇殑璧勬簮銆?
statement.close();
con.close();
//鎶婇〉闈㈡淳鍙戝埌鐩殑
response.sendRedirect("index.jsp");
}
%>
include.inc濡備笅锛?
<%@ page import="java.sql.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.io.*"%>
<%@ page import="com.microsoft.jdbc.sqlserver.SQLServerDriver"%>
<%@ page import="java.lang.*"%>
<%@ page contentType="text/html; charset=gb2312" %>
<%
request.setCharacterEncoding("gb2312");
String CLASSFORNAME="com.microsoft.jdbc.sqlserver.SQLServerDriver";
String SERVANDDB="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=jspdev";
String USER="";
String PWD="";
%>
褰撳湪杈撳叆http://127.0.0.1:8080/jspdev/login.jsp鍚庛€傚湪椤甸潰涓緭鍏ョ敤鎴峰悕锛歨ellking 瀵嗙爜锛?
hellking鍚庢彁浜ゅ嚭鐜板涓嬮敊璇細
46 涓В鍐虫柟妗?/h2>
#1
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling
this request.
exception
javax.servlet.ServletException: [Microsoft][SQLServer 2000 Driver for JDBC]Error
establishing socket.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException
(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException
(PageContextImpl.java:758)
org.apache.jsp.login_jsp._jspService(login_jsp.java:125)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.jspdev.ch8.EncodingFilter.doFilter(EncodingFilter.java:36)
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(DriverManager.java:512)
java.sql.DriverManager.getConnection(DriverManager.java:171)
org.apache.jsp.login_jsp._jspService(login_jsp.java:81)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.jspdev.ch8.EncodingFilter.doFilter(EncodingFilter.java:36)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
--------------------------------------------------------------------------------
Apache Tomcat/5.0.28
#2
寤虹珛濂楁帴瀛楅敊,濂借薄鏄綉缁滈敊璇?
#3
鏁版嵁搴撻┍鍔ㄧ▼搴忔湁闂銆傛病鏈夋垚鍔熷缓绔嬫暟鎹簱杩炴帴銆?
#4
閭h浠€涔堝仛鍟婏紝鎴戞槸鎶奙icrosoft SQL Server 2000 Driver for JDBC瑁呭湪C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC涓嬬殑锛岃兘涓嶈兘缁欎釜鍏蜂綋鐨勮娉曞悧锛?
#5
杩樺ソ浜嗭紝鎴戠幇鍦ㄨ繕閮戒笉鐭ラ亾浠€涔堟槸杩炴帴姹?
#6
鏁版嵁搴搖rl鐨勭鍙e彿1433鏄惁姝g‘鍛紵鎶?27.0.0.1鎹㈡垚localhost鎴栬€呬綘鏈哄櫒鐨処P璇曚竴涓嬨€?
#7
鏁版嵁搴撻┍鍔ㄧ殑3JAR鏂囦欢鍔犺浇浜嗘病锛?
灏戜竴涓笉琛?
#8
鎴戞妸杩檓ssqlserver 锛?nbsp;msbase锛?nbsp;msutil杩欎笁涓枃浠堕兘鎸庡埌浜咰:\jakarta-tomcat-5.0.28\jakarta-tomcat-5.0.28\common\lib鐩笅浜嗐€?
#9
楂樻墜甯府灏忓紵鍚э紝鎴戠幇鍦ㄥ緢鎬ュ晩锛?
鎴戝疄鎵炬槸鎵句笉鍒颁粈涔堝師鍥犱簡锛屼笉鐭ラ亾閿欏湪鍝?nbsp;閲屼簡锛孧icrosoft SQL Server 2000 Driver for JDBC鎴戜篃瑁呬簡锛屼笁涓枃浠舵垜涔熸寧鍒颁簡C:\jakarta-tomcat-5.0.28\jakarta-tomcat-5.0.28\common\lib鐩笅浜嗐€傚氨鏄竴鐩磋繍琛屼笉琛屽晩锛侊紒
#10
hao濂藉儚鏄病鏈夊0鏄庨┍鍔ㄥ憖锛屼笉鐭ヤ綘鐢ㄧ殑鏄痵qlserver杩樻槸浠€涔?
#11
鎴戠敤鐨勬槸sqlserver2000 杩欎釜瑕佷笉瑕佽缃甇DBC鏁版嵁婧愬憿锛?
#12
鎶婅繖mssqlserver 锛?nbsp;msbase锛?nbsp;msutil杩欎笁涓枃浠舵斁鍒皐ebapp涓嬬殑WEB-INF/LIB涓嬭竟璇曡瘯锛?
#13
鏁版嵁搴撻┍鍔ㄧ殑闂鍛€锛?
#14
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
浣犲ソ鍍忓皯鍐欎簡涓滆タ鍟婏紒锛侊紒锛?
#15
浣犲皯鍐欎簡.newInstance()
#16
鏈夊晩锛屾垜鎶婅繖浜涘叏鏀惧湪include.inc閲岄潰浜?
鍒板簳閿欏湪閭i噷锛?
#17
copy杩涘幓鍚庯紝閲嶅惎杩囦簡涔堬紵
#18
閮借瘯杩囦簡锛屽ぇ瀹惰鐨勬垜閮借瘯杩囦簡锛屽氨鏄笉鐭ラ亾浠€涔堝姙鍟?
浼氫笉浼氳窡鏁版嵁搴撴斁鐨勪綅缃湁鍏崇郴鍟?
#19
鏁版嵁搴撶殑鐢ㄦ埛鍚嶏紝瀵嗙爜閮戒负绌轰箞锛?
#20
鏄晩锛屾垜鍦ㄦ寜瑁匰QLserver2000鏃跺氨娌℃湁璁剧敤鎴峰悕鍜屽瘑鐮佹墍浠ユ垜璁や负搴旀槸绌虹殑鍚э紒
#21
浼氱殑甯垜涓€涓嬪惂锛?
瑙e喅绔嬭鍏冲笎
#22
楂樻墜鍟婏紝璺眰鍟?
#23
浣犵殑杩炴帴鏁版嵁搴撶殑鐢ㄦ埛鍚嶄负绌猴紝杩欐槸涓嶈鐨勶紝鑰屼笖SQL銆€SERVER涔熶笉鏀寔绌虹敤鎴峰悕鐨勩€傜敤JDBC杩炴帴SQL銆€SERVER鐨勬椂鍊欏ソ璞$敤鎴峰悕鍜屽瘑鐮佷笉鑳戒负绌虹殑锛岀敤ODBC鐨勬椂鍊橲QL銆€SEVER灏变笉鑳芥湁绌哄瘑鐮佺殑锛屽惁鍒欒繛涓嶄笂鐨勩€備綘鍏堝啓涓€涓繛鎺ユ暟鎹簱鐨勬祴璇曠▼搴忚瘯璇曞彲椐e彲浠ョ敤绌虹殑瀵嗙爜鐨勩€傜湅鐢ㄦ埛鍚嶅拰瀵嗙爜鍙笉鍙负绌恒€?
#24
浣犲湪鎸夎SQLserver2000鏃跺氨娌℃湁璁剧敤鎴峰悕鍜屽瘑鐮侊紝骞朵笉鑳借涓哄簲鏄┖鐨勶紝SQL銆€SERVER鐨勯粯璁ょ敤鎴峰悕鏄痵a,骞朵笉鏄病鏈夌敤鎴峰悕锛屾墍浠ヤ綘鐨勭▼搴忎腑鐨刄SER鐨勫€艰鏄痵a,鍙槸浣犳病鏈夊瘑鐮侊紝瀹冪殑鍊兼墠涓虹┖銆?
#25
鏈€鍚庢槸鍦⊿QL銆€SERVER涓暟鎹簱鐨勫睘鎬т腑涓簊a鐢ㄦ埛璁剧疆涓€涓瘑鐮侊紝瑕佸畨鍏ㄤ竴浜涖€?
#26
drugon(personal锛夛細鎴戠幇宸叉妸鐢ㄦ埛鍚嶈涓簎ser鍜屽瘑鐮佷负user鍙槸杩欐牱杩樻槸涓嶈鍟婏紒
#27
浣犵湅涓€涓嬫垜鍐欑殑SQLSERVER2000鐨勮繛鎺ワ紝濡傛灉鏄繛鎺ョ殑闂锛屼綘鍏堟妸杩炴帴鍐欏埌BEAN鎴栨槸鐩存帴鍐欏埌JSP椤甸潰閲屽幓璇曚竴璇曪紝鎶婁綘鐨勮繛鎺ラ儴鍒嗘崲鎴愭垜鐨勫氨鑲畾娌℃湁闂浜嗭紙鎴戞槸鍐欏湪BEAN閲岄潰鐨勶級
public Connection connect() throws Exception {
try {
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver")
.newInstance();
System.out.println("jdbc loading....");
String url = "jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=cctest";
String user = "sa";
String password = "manager";
con = DriverManager.getConnection(url, user, password);
return con;
} catch (Exception e) {
error = "EXC:Connection to database was lost";
throw new Exception(error);
}
}
#28
杩欐牱鍐欑殑璺熼偅鏍锋湁鍏风殑鐨勫尯鍒悧锛?
#29
鎴戝師浠ヤ负鏄粈涔堥敊浜嗭紝鎴戝氨鍐嶅彟鍐欎竴涓紝鏁版嵁搴撹繛鎺ワ紝鍙槸涔熶竴鏍峰嚭鐜颁笂闈㈢殑閭f牱鍑洪敊鐨勬彁绀猴紵锛?
#30
涓嬭浇SQL Server 2000 Driver for JDBC Service Pack 3
http://www.microsoft.com/downloads/details.aspx?FamilyId=07287B11-0502-461A-B138-2AA54BFDC03A&displaylang=en
涓嬩簡瑁呬笂鐪嬬湅
#31
妫€鏌ラ槻鐏锛宨p鍦板潃锛屽鏋滈兘娌¢棶棰橀偅灏辨槸鎿嶄綔绯荤粺鐨勪簨鍎夸簡
濡傛灉鏄痻p(sp1)浠ヤ笂鐨勭増鏈紝Service Pack 3琛ヤ竵瑁呬笂锛岃涓婁簡鍙兘浼氬ソ浣匡紝win2000浠ヤ笂鐨勬搷浣滅郴缁熻浜唖ql2000涓€鑸兘浼氬嚭鐜拌繖绉嶉棶棰橈紝褰撳垵杩欎釜闂鎶樼(浜嗘垜涓ゅぉ涓ゅ锛堟睏锛夛紒寤鸿浣犳渶濂借xp(sp1鐗?鐨勶紝杩欐槸缁堟瀬瑙e喅鍔炴硶锛侊紒锛佸墠鎻愭槸浣犺瀹宻p3琛ヤ竵鍚庝粛鐒惰繛鎺ヤ笉涓?
#32
鎴戠敤鐨勬槸XP(SP2)锛屽ソ鐨勶紝鎴戣瘯涓嬬湅琛屼笉琛岋紵
#33
鍚勪綅澶у摜鎴戣瘯浜嗚繕鏄笉琛岋紵
#34
浼拌鏄綘鐨勬暟鎹簱椹卞姩娌″紕濂?
#35
搴旇涓嶆槸椹卞姩鐨勯棶棰?
浣犵殑sa鐢ㄦ埛鐨勫瘑鐮佹槸涓嶆槸manager鍛€?
浣犲厛鐢ㄥ瘑鐮佷负manager鐨勭敤鎴穝a鐢∣DBC杩炵殑璇曡瘯鐪?濡傛灉鍙互閭e氨涓嶆槸椹卞姩鐨勯棶棰?鍙兘鏄叾瀹冪殑鍘熷洜,鎴栬€呬綘鎶妔p2鍖呭嵏鎺夎瘯璇?浠ュ墠濂借薄鐪嬪埌鍒汉涔熷嚭鐜拌繃杩欐牱鐨勯棶棰?
#36
鎴戣瘯杩囦簡杩樻槸涓嶈銆傛垜鏄敤鎴戠郴缁熺櫥褰曠殑鐢ㄦ埛鐨勫瘑鐮佷綔涓鸿繛鎺ユ暟鎹簱鐨勭殑锛屼笉鐭ラ亾鏄笉鏄繖涓晩锛?
褰撶劧鎴戜篃鐢⊿A鍜岀櫥褰曞瘑鐮佽瘯杩囧氨鏄笉琛屽晩锛佷笉鐭ラ亾鍚勪綅澶у摜浠垜杩欐牱鍋氭槸涓嶆槸鍙互鍟婏紝鎴戞槸涓垵瀛﹁€呬笉鐭ラ亾閿欏湪閭i噷浜?
#37
drugon(personal) 锛氱敤ODBC濡備綍鍐欎綘鑳藉府鎴戝啓涓€涓垜璇曡瘯鐪嬭兘涓嶈兘杩烇紵
#38
璋㈣阿澶у鐨勶紝鎻愮ず鍟婏紝鎴戞妸椹卞姩绋嬪簭鏀规垚JDBC-ODBC杩炴帴灏卞彲浠ヤ簡锛屽彧鏄綋鎴戣緭鍏ョ敤鎴峰悕锛屽杈撳叆閿欏氨鍙槸杈惧埌瑕佹眰锛屼絾鏄緭鍏ellking涔熷氨鏄緭鍏ユ纭殑鐢ㄦ埛鍚嶄笌瀵嗙爜鏃讹紝灏辨彁绀哄涓嬮敊璇紝涓嶇煡閬撻敊鍦ㄥ摢 閲岋紵
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: [Microsoft][ODBC SQL Server Driver]鏃犳晥鐨勬弿杩扮绱㈠紩
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.login_jsp._jspService(login_jsp.java:123)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.jspdev.ch8.EncodingFilter.doFilter(EncodingFilter.java:36)
root cause
java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]鏃犳晥鐨勬弿杩扮绱㈠紩
sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958)
sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)
sun.jdbc.odbc.JdbcOdbc.SQLGetDataString(JdbcOdbc.java:3908)
sun.jdbc.odbc.JdbcOdbcResultSet.getDataString(JdbcOdbcResultSet.java:5702)
sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:356)
sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:413)
org.apache.jsp.login_jsp._jspService(login_jsp.java:97)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.jspdev.ch8.EncodingFilter.doFilter(EncodingFilter.java:36)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
--------------------------------------------------------------------------------
Apache Tomcat/5.0.28
#39
statement.execute("update user_info set userLogCount="+count+",userLastLogTime='"+sqltime+"' where userId='" + id +"'");
鎵ц杩欏彞鏃舵湁闂鍚?nbsp;
鍓嶉潰浣犱笉鏄?nbsp;statement.close() 浜嗗悧
#40
椋炴€濋偅鏈琷sp涔︿笂鐨勪唬鐮佹病鏈夎兘鎴愬姛鐨?鏈€濂借嚜宸变竴姝ヤ竴姝ュ仛.閭f湰涔﹀彧鑳藉仛涓哄弬鑰?
#41
閭d笁涓枃浠舵斁涓€濂楀埌\jdk\jre\lib\ext涓嬮潰锛岃繕鏈夋祴璇曟椂鏈€濂藉皯鍐欐敞閲婏紝鍚﹀垯鏈夊彲鑳介亣鍒板啿绐侊紝锛堝ぉ鍙€滆锛岃繖绉嶉棶棰樹亢閬囪杩囷級銆傛垜鐨勯┍鍔ㄦ斁鍒皌omcat閲屾牴鏈笉琛岋紝鎴戜篃涓嶇煡閬撲负浠€涔堛€?
#42
鍚屾劅鍟婏紝鎴戝氨鏄敤椋炴€濈浜岀増鍟婏紝瑙夌殑濂藉浠g爜閿欙紵
#43
锛滐紞锛嶏紞锛嶏紞锛嶏紞锛嶏紞锛嶏紞锛嶏紞锛嶉珮鎵嬬湅杩囨潵锛?nbsp;鑳戒笉鑳芥悶瀹氳繖涓紵
http://community.csdn.net/Expert/topic/3472/3472337.xml?temp=.2961847
#44
棣栧厛璺熶綘璇翠竴鐐?
鍦╯ql server 2000涓? 濡傛灉浣犳槸鐢ㄧ櫥闄嗙郴缁熺殑甯愬彿鍘绘墦寮€鏁版嵁搴撶殑鏄笉琛岀殑,浣犲憜浠ユ墦寮€鏄洜涓虹殑浣犳暟鎹簱瓒呯骇鐢ㄦ埛sa娌℃湁璁剧疆瀵嗙爜,鎵€浠ヤ綘鍙互鎵撳紑.浣嗘槸鍦ㄧ敤ODBC鐨勬椂鍊欏氨涓嶈浜?瀹冭姹備綘杈撳叆瀵嗙爜,鎴戜互鍓嶈瘯杩?鏄笉琛岀殑.鐜板湪娌¤瀹?鎵€浠ュ氨涓嶇煡閬撲簡,涓嶇煡閬撴湁娌℃湁浜鸿瘯杩囨垚鍔熶簡鐨?
浣嗘槸鍦╯ql server 2000涓張鏈夐偅涓€椤?鍙互鐢ㄧ櫥闄嗙郴缁熺殑甯愬彿鍘荤櫥闄嗘暟鎹簱.閭h鍦ㄦ暟鎹簱涓仛鐩稿簲鐨勮缃墠鍙互.涓嶈缃槸涓嶈浜?
鐧婚檰绯荤粺鐨勫笎鍙峰拰鐧婚檰鏁版嵁搴撶殑甯愬彿鏄袱鍥炰簨,鏄笉涓€鏍风殑.SQL Server 2000鐨勮秴绾х敤鎴峰悕鏄痵a ,瀹冪殑鍚嶅瓧鏄笉鑳芥洿鏀圭殑.灏辫薄windows鐨刟dministrator甯愬彿涓€鏍?nbsp;(unix涓槸root).
涓嬮潰鎴戠粰涓€涓狾DBC-JDBC鐨勪緥瀛愬亣璁句綘鍏堝湪"鎺у埗闈㈡澘"涓殑"绠$悊宸ュ叿"涓殑"ODBC鏁版嵁婧?涓繁缁忓缓浜嗕竴涓悕瀛椾负"DataBase"鐨?绯荤粺DNS鏁版嵁婧?.瀹冪殑鐢ㄦ埛鍚嶄负"test",瀵嗙爜涔熶负"test".鍋囪瀹冭繛鎺ョ殑鏄竴涓猘ccess,瀹冨叾涓殑鏁版嵁搴撶殑鍚嶅瓧涓?company",鍏朵腑鏈変竴涓〃鍚嶅瓧涓?employer".
import java.sql.*;
public class DatabaseProductName
{
public static void main(String[] args)
{
Connection con;
Statement stat;
DatabaseMetaData meta;
ResultSet set,info,res;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch (ClassNotFoundException e)
{
System.out.println("Load Driver exception ->"+e);
}
try
{
con=DriverManager.getConnection("jdbc:odbc:DataBase","test","test");
meta=con.getMetaData();
System.out.println("getDatabaseProductName()->"+meta.getDatabaseProductName());
System.out.println("getSchemaTerm() ->"+meta.getSchemaTerm() );
System.out.println("getURL() ->"+meta.getURL() );
System.out.println("getUserName() ->"+meta.getUserName() );
set=meta.getCatalogs();
while (set.next())
{
System.out.println("TABLE_SCHEM ->"+set.getString(1));
}
String type[]={"TABLE"};
String column[]={"TABLE_CAT","TABLE_SCHEM","TABLE_NAME","TABLE_TYPE","REMARKS"};
info=meta.getTables(null,null,"%",type);
ResultSetMetaData me=info.getMetaData();
for (int i=1;i<=me.getColumnCount();i++)
System.out.println(me.getColumnName(i));
while (info.next())
{
for (int i=1;i<=5;i++)
System.out.println(column[i-1]+"<----->"+info.getString(i));
System.out.println();
}
}
catch(SQLException e)
{
System.out.println("SQLException ->"+e);
}//ÉÏÃæµÄÕâЩ¶¼ÊÇһЩµÃµ½Êý¾Ý¿âµÄÐÅÏ¢µÄ,Äã¿ÉÒÔ²»¿´.ÏÂÃæµÄÊÇÒ»¸öÍ锚ÕûµÄÀý脳Ó
try
{
stat=con.createStatement();
res=stat.executeQuery("select * from employer");
while (res.next())
{
System.out.println(res.getString("name")); //name ÊÇ卤铆employerÖеÄÒ»ÁÐ
System.out.println(res.getInt("age")); //age ÊÇ卤铆employerÖеÄÒ»ÁÐ
.......
}
}
catch (SQLException e)
{
System.out.pintln(e);
}
finally
{
try
{
if (con!=null)
con.close();
}
catch (SQLException e)
{
System.out.println("close exception "+e);
}
}
}
}
#45
涓嶅ソ鎰忔€濆垰鎵嶇矘璐翠唬鐮佸嚭浜嗙偣闂,閲嶆柊绮樹竴娆?
import java.sql.*;
public class DatabaseProductName
{
public static void main(String[] args)
{
Connection con;
Statement stat;
DatabaseMetaData meta;
ResultSet set,info,res;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch (ClassNotFoundException e)
{
System.out.println("Load Driver exception ->"+e);
}
try
{
con=DriverManager.getConnection("jdbc:odbc:DataBase","test","test");
meta=con.getMetaData();
System.out.println("getDatabaseProductName()->"+meta.getDatabaseProductName());
System.out.println("getSchemaTerm() ->"+meta.getSchemaTerm() );
System.out.println("getURL() ->"+meta.getURL() );
System.out.println("getUserName() ->"+meta.getUserName() );
set=meta.getCatalogs();
while (set.next())
{
System.out.println("TABLE_SCHEM ->"+set.getString(1));
}
String type[]={"TABLE"};
String column[]={"TABLE_CAT","TABLE_SCHEM","TABLE_NAME","TABLE_TYPE","REMARKS"};
info=meta.getTables(null,null,"%",type);
ResultSetMetaData me=info.getMetaData();
for (int i=1;i<=me.getColumnCount();i++)
System.out.println(me.getColumnName(i));
while (info.next())
{
for (int i=1;i<=5;i++)
System.out.println(column[i-1]+"<----->"+info.getString(i));
System.out.println();
}
}
catch(SQLException e)
{
System.out.println("SQLException ->"+e);
}//杩欎笂闈㈢殑浣犲彲浠ヤ笉鐪?瀹冩槸寰楀埌涓€涓暟鎹簱鐨勪竴浜涗俊鎭?涓嬮潰鐨勬槸涓€涓畬鏁寸殑渚嬪瓙.
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch (ClassNotFoundException e)
{
System.out.println("Load Driver exception ->"+e);
} //杩欎釜try--catch鍙互涓嶈,鍥犱负鏈€涓婇潰鐨?鏀惧湪杩欓噷鏄兂鎶婁笅闈㈢殑鍋氫负涓€涓畬鏁寸殑渚嬪瓙,鏂逛究浣犺鐪?
try
{
stat=con.createStatement();
res=stat.executeQuery("select * from employer");
while (res.next())
{
System.out.println(res.getString("name")); //name ÊÇ卤铆employerÖеÄÒ»ÁÐ
System.out.println(res.getInt("age")); //age ÊÇ卤铆employerÖеÄÒ»ÁÐ
.......
}
}
catch (SQLException e)
{
System.out.pintln(e);
}
finally
{
try
{
if (con!=null)
con.close();
}
catch (SQLException e)
{
System.out.println("close exception "+e);
}
}
}
}
#46
杩樻湁闂鐨勮瘽.鍔犳垜msn鍚?rogerliu@mango.cc
#1
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling
this request.
exception
javax.servlet.ServletException: [Microsoft][SQLServer 2000 Driver for JDBC]Error
establishing socket.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException
(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException
(PageContextImpl.java:758)
org.apache.jsp.login_jsp._jspService(login_jsp.java:125)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.jspdev.ch8.EncodingFilter.doFilter(EncodingFilter.java:36)
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(DriverManager.java:512)
java.sql.DriverManager.getConnection(DriverManager.java:171)
org.apache.jsp.login_jsp._jspService(login_jsp.java:81)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.jspdev.ch8.EncodingFilter.doFilter(EncodingFilter.java:36)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
--------------------------------------------------------------------------------
Apache Tomcat/5.0.28
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling
this request.
exception
javax.servlet.ServletException: [Microsoft][SQLServer 2000 Driver for JDBC]Error
establishing socket.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException
(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException
(PageContextImpl.java:758)
org.apache.jsp.login_jsp._jspService(login_jsp.java:125)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.jspdev.ch8.EncodingFilter.doFilter(EncodingFilter.java:36)
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(DriverManager.java:512)
java.sql.DriverManager.getConnection(DriverManager.java:171)
org.apache.jsp.login_jsp._jspService(login_jsp.java:81)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.jspdev.ch8.EncodingFilter.doFilter(EncodingFilter.java:36)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
--------------------------------------------------------------------------------
Apache Tomcat/5.0.28
#2
寤虹珛濂楁帴瀛楅敊,濂借薄鏄綉缁滈敊璇?
#3
鏁版嵁搴撻┍鍔ㄧ▼搴忔湁闂銆傛病鏈夋垚鍔熷缓绔嬫暟鎹簱杩炴帴銆?
#4
閭h浠€涔堝仛鍟婏紝鎴戞槸鎶奙icrosoft SQL Server 2000 Driver for JDBC瑁呭湪C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC涓嬬殑锛岃兘涓嶈兘缁欎釜鍏蜂綋鐨勮娉曞悧锛?
#5
杩樺ソ浜嗭紝鎴戠幇鍦ㄨ繕閮戒笉鐭ラ亾浠€涔堟槸杩炴帴姹?
#6
鏁版嵁搴搖rl鐨勭鍙e彿1433鏄惁姝g‘鍛紵鎶?27.0.0.1鎹㈡垚localhost鎴栬€呬綘鏈哄櫒鐨処P璇曚竴涓嬨€?
#7
鏁版嵁搴撻┍鍔ㄧ殑3JAR鏂囦欢鍔犺浇浜嗘病锛?
灏戜竴涓笉琛?
灏戜竴涓笉琛?
#8
鎴戞妸杩檓ssqlserver 锛?nbsp;msbase锛?nbsp;msutil杩欎笁涓枃浠堕兘鎸庡埌浜咰:\jakarta-tomcat-5.0.28\jakarta-tomcat-5.0.28\common\lib鐩笅浜嗐€?
#9
楂樻墜甯府灏忓紵鍚э紝鎴戠幇鍦ㄥ緢鎬ュ晩锛?
鎴戝疄鎵炬槸鎵句笉鍒颁粈涔堝師鍥犱簡锛屼笉鐭ラ亾閿欏湪鍝?nbsp;閲屼簡锛孧icrosoft SQL Server 2000 Driver for JDBC鎴戜篃瑁呬簡锛屼笁涓枃浠舵垜涔熸寧鍒颁簡C:\jakarta-tomcat-5.0.28\jakarta-tomcat-5.0.28\common\lib鐩笅浜嗐€傚氨鏄竴鐩磋繍琛屼笉琛屽晩锛侊紒
鎴戝疄鎵炬槸鎵句笉鍒颁粈涔堝師鍥犱簡锛屼笉鐭ラ亾閿欏湪鍝?nbsp;閲屼簡锛孧icrosoft SQL Server 2000 Driver for JDBC鎴戜篃瑁呬簡锛屼笁涓枃浠舵垜涔熸寧鍒颁簡C:\jakarta-tomcat-5.0.28\jakarta-tomcat-5.0.28\common\lib鐩笅浜嗐€傚氨鏄竴鐩磋繍琛屼笉琛屽晩锛侊紒
#10
hao濂藉儚鏄病鏈夊0鏄庨┍鍔ㄥ憖锛屼笉鐭ヤ綘鐢ㄧ殑鏄痵qlserver杩樻槸浠€涔?
#11
鎴戠敤鐨勬槸sqlserver2000 杩欎釜瑕佷笉瑕佽缃甇DBC鏁版嵁婧愬憿锛?
#12
鎶婅繖mssqlserver 锛?nbsp;msbase锛?nbsp;msutil杩欎笁涓枃浠舵斁鍒皐ebapp涓嬬殑WEB-INF/LIB涓嬭竟璇曡瘯锛?
#13
鏁版嵁搴撻┍鍔ㄧ殑闂鍛€锛?
#14
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
浣犲ソ鍍忓皯鍐欎簡涓滆タ鍟婏紒锛侊紒锛?
浣犲ソ鍍忓皯鍐欎簡涓滆タ鍟婏紒锛侊紒锛?
#15
浣犲皯鍐欎簡.newInstance()
#16
鏈夊晩锛屾垜鎶婅繖浜涘叏鏀惧湪include.inc閲岄潰浜?
鍒板簳閿欏湪閭i噷锛?
鍒板簳閿欏湪閭i噷锛?
#17
copy杩涘幓鍚庯紝閲嶅惎杩囦簡涔堬紵
#18
閮借瘯杩囦簡锛屽ぇ瀹惰鐨勬垜閮借瘯杩囦簡锛屽氨鏄笉鐭ラ亾浠€涔堝姙鍟?
浼氫笉浼氳窡鏁版嵁搴撴斁鐨勪綅缃湁鍏崇郴鍟?
浼氫笉浼氳窡鏁版嵁搴撴斁鐨勪綅缃湁鍏崇郴鍟?
#19
鏁版嵁搴撶殑鐢ㄦ埛鍚嶏紝瀵嗙爜閮戒负绌轰箞锛?
#20
鏄晩锛屾垜鍦ㄦ寜瑁匰QLserver2000鏃跺氨娌℃湁璁剧敤鎴峰悕鍜屽瘑鐮佹墍浠ユ垜璁や负搴旀槸绌虹殑鍚э紒
#21
浼氱殑甯垜涓€涓嬪惂锛?
瑙e喅绔嬭鍏冲笎
瑙e喅绔嬭鍏冲笎
#22
楂樻墜鍟婏紝璺眰鍟?
#23
浣犵殑杩炴帴鏁版嵁搴撶殑鐢ㄦ埛鍚嶄负绌猴紝杩欐槸涓嶈鐨勶紝鑰屼笖SQL銆€SERVER涔熶笉鏀寔绌虹敤鎴峰悕鐨勩€傜敤JDBC杩炴帴SQL銆€SERVER鐨勬椂鍊欏ソ璞$敤鎴峰悕鍜屽瘑鐮佷笉鑳戒负绌虹殑锛岀敤ODBC鐨勬椂鍊橲QL銆€SEVER灏变笉鑳芥湁绌哄瘑鐮佺殑锛屽惁鍒欒繛涓嶄笂鐨勩€備綘鍏堝啓涓€涓繛鎺ユ暟鎹簱鐨勬祴璇曠▼搴忚瘯璇曞彲椐e彲浠ョ敤绌虹殑瀵嗙爜鐨勩€傜湅鐢ㄦ埛鍚嶅拰瀵嗙爜鍙笉鍙负绌恒€?
#24
浣犲湪鎸夎SQLserver2000鏃跺氨娌℃湁璁剧敤鎴峰悕鍜屽瘑鐮侊紝骞朵笉鑳借涓哄簲鏄┖鐨勶紝SQL銆€SERVER鐨勯粯璁ょ敤鎴峰悕鏄痵a,骞朵笉鏄病鏈夌敤鎴峰悕锛屾墍浠ヤ綘鐨勭▼搴忎腑鐨刄SER鐨勫€艰鏄痵a,鍙槸浣犳病鏈夊瘑鐮侊紝瀹冪殑鍊兼墠涓虹┖銆?
#25
鏈€鍚庢槸鍦⊿QL銆€SERVER涓暟鎹簱鐨勫睘鎬т腑涓簊a鐢ㄦ埛璁剧疆涓€涓瘑鐮侊紝瑕佸畨鍏ㄤ竴浜涖€?
#26
drugon(personal锛夛細鎴戠幇宸叉妸鐢ㄦ埛鍚嶈涓簎ser鍜屽瘑鐮佷负user鍙槸杩欐牱杩樻槸涓嶈鍟婏紒
#27
浣犵湅涓€涓嬫垜鍐欑殑SQLSERVER2000鐨勮繛鎺ワ紝濡傛灉鏄繛鎺ョ殑闂锛屼綘鍏堟妸杩炴帴鍐欏埌BEAN鎴栨槸鐩存帴鍐欏埌JSP椤甸潰閲屽幓璇曚竴璇曪紝鎶婁綘鐨勮繛鎺ラ儴鍒嗘崲鎴愭垜鐨勫氨鑲畾娌℃湁闂浜嗭紙鎴戞槸鍐欏湪BEAN閲岄潰鐨勶級
public Connection connect() throws Exception {
try {
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver")
.newInstance();
System.out.println("jdbc loading....");
String url = "jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=cctest";
String user = "sa";
String password = "manager";
con = DriverManager.getConnection(url, user, password);
return con;
} catch (Exception e) {
error = "EXC:Connection to database was lost";
throw new Exception(error);
}
}
public Connection connect() throws Exception {
try {
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver")
.newInstance();
System.out.println("jdbc loading....");
String url = "jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=cctest";
String user = "sa";
String password = "manager";
con = DriverManager.getConnection(url, user, password);
return con;
} catch (Exception e) {
error = "EXC:Connection to database was lost";
throw new Exception(error);
}
}
#28
杩欐牱鍐欑殑璺熼偅鏍锋湁鍏风殑鐨勫尯鍒悧锛?
#29
鎴戝師浠ヤ负鏄粈涔堥敊浜嗭紝鎴戝氨鍐嶅彟鍐欎竴涓紝鏁版嵁搴撹繛鎺ワ紝鍙槸涔熶竴鏍峰嚭鐜颁笂闈㈢殑閭f牱鍑洪敊鐨勬彁绀猴紵锛?
#30
涓嬭浇SQL Server 2000 Driver for JDBC Service Pack 3
http://www.microsoft.com/downloads/details.aspx?FamilyId=07287B11-0502-461A-B138-2AA54BFDC03A&displaylang=en
涓嬩簡瑁呬笂鐪嬬湅
http://www.microsoft.com/downloads/details.aspx?FamilyId=07287B11-0502-461A-B138-2AA54BFDC03A&displaylang=en
涓嬩簡瑁呬笂鐪嬬湅
#31
妫€鏌ラ槻鐏锛宨p鍦板潃锛屽鏋滈兘娌¢棶棰橀偅灏辨槸鎿嶄綔绯荤粺鐨勪簨鍎夸簡
濡傛灉鏄痻p(sp1)浠ヤ笂鐨勭増鏈紝Service Pack 3琛ヤ竵瑁呬笂锛岃涓婁簡鍙兘浼氬ソ浣匡紝win2000浠ヤ笂鐨勬搷浣滅郴缁熻浜唖ql2000涓€鑸兘浼氬嚭鐜拌繖绉嶉棶棰橈紝褰撳垵杩欎釜闂鎶樼(浜嗘垜涓ゅぉ涓ゅ锛堟睏锛夛紒寤鸿浣犳渶濂借xp(sp1鐗?鐨勶紝杩欐槸缁堟瀬瑙e喅鍔炴硶锛侊紒锛佸墠鎻愭槸浣犺瀹宻p3琛ヤ竵鍚庝粛鐒惰繛鎺ヤ笉涓?
濡傛灉鏄痻p(sp1)浠ヤ笂鐨勭増鏈紝Service Pack 3琛ヤ竵瑁呬笂锛岃涓婁簡鍙兘浼氬ソ浣匡紝win2000浠ヤ笂鐨勬搷浣滅郴缁熻浜唖ql2000涓€鑸兘浼氬嚭鐜拌繖绉嶉棶棰橈紝褰撳垵杩欎釜闂鎶樼(浜嗘垜涓ゅぉ涓ゅ锛堟睏锛夛紒寤鸿浣犳渶濂借xp(sp1鐗?鐨勶紝杩欐槸缁堟瀬瑙e喅鍔炴硶锛侊紒锛佸墠鎻愭槸浣犺瀹宻p3琛ヤ竵鍚庝粛鐒惰繛鎺ヤ笉涓?
#32
鎴戠敤鐨勬槸XP(SP2)锛屽ソ鐨勶紝鎴戣瘯涓嬬湅琛屼笉琛岋紵
#33
鍚勪綅澶у摜鎴戣瘯浜嗚繕鏄笉琛岋紵
#34
浼拌鏄綘鐨勬暟鎹簱椹卞姩娌″紕濂?
#35
搴旇涓嶆槸椹卞姩鐨勯棶棰?
浣犵殑sa鐢ㄦ埛鐨勫瘑鐮佹槸涓嶆槸manager鍛€?
浣犲厛鐢ㄥ瘑鐮佷负manager鐨勭敤鎴穝a鐢∣DBC杩炵殑璇曡瘯鐪?濡傛灉鍙互閭e氨涓嶆槸椹卞姩鐨勯棶棰?鍙兘鏄叾瀹冪殑鍘熷洜,鎴栬€呬綘鎶妔p2鍖呭嵏鎺夎瘯璇?浠ュ墠濂借薄鐪嬪埌鍒汉涔熷嚭鐜拌繃杩欐牱鐨勯棶棰?
浣犵殑sa鐢ㄦ埛鐨勫瘑鐮佹槸涓嶆槸manager鍛€?
浣犲厛鐢ㄥ瘑鐮佷负manager鐨勭敤鎴穝a鐢∣DBC杩炵殑璇曡瘯鐪?濡傛灉鍙互閭e氨涓嶆槸椹卞姩鐨勯棶棰?鍙兘鏄叾瀹冪殑鍘熷洜,鎴栬€呬綘鎶妔p2鍖呭嵏鎺夎瘯璇?浠ュ墠濂借薄鐪嬪埌鍒汉涔熷嚭鐜拌繃杩欐牱鐨勯棶棰?
#36
鎴戣瘯杩囦簡杩樻槸涓嶈銆傛垜鏄敤鎴戠郴缁熺櫥褰曠殑鐢ㄦ埛鐨勫瘑鐮佷綔涓鸿繛鎺ユ暟鎹簱鐨勭殑锛屼笉鐭ラ亾鏄笉鏄繖涓晩锛?
褰撶劧鎴戜篃鐢⊿A鍜岀櫥褰曞瘑鐮佽瘯杩囧氨鏄笉琛屽晩锛佷笉鐭ラ亾鍚勪綅澶у摜浠垜杩欐牱鍋氭槸涓嶆槸鍙互鍟婏紝鎴戞槸涓垵瀛﹁€呬笉鐭ラ亾閿欏湪閭i噷浜?
褰撶劧鎴戜篃鐢⊿A鍜岀櫥褰曞瘑鐮佽瘯杩囧氨鏄笉琛屽晩锛佷笉鐭ラ亾鍚勪綅澶у摜浠垜杩欐牱鍋氭槸涓嶆槸鍙互鍟婏紝鎴戞槸涓垵瀛﹁€呬笉鐭ラ亾閿欏湪閭i噷浜?
#37
drugon(personal) 锛氱敤ODBC濡備綍鍐欎綘鑳藉府鎴戝啓涓€涓垜璇曡瘯鐪嬭兘涓嶈兘杩烇紵
#38
璋㈣阿澶у鐨勶紝鎻愮ず鍟婏紝鎴戞妸椹卞姩绋嬪簭鏀规垚JDBC-ODBC杩炴帴灏卞彲浠ヤ簡锛屽彧鏄綋鎴戣緭鍏ョ敤鎴峰悕锛屽杈撳叆閿欏氨鍙槸杈惧埌瑕佹眰锛屼絾鏄緭鍏ellking涔熷氨鏄緭鍏ユ纭殑鐢ㄦ埛鍚嶄笌瀵嗙爜鏃讹紝灏辨彁绀哄涓嬮敊璇紝涓嶇煡閬撻敊鍦ㄥ摢 閲岋紵
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: [Microsoft][ODBC SQL Server Driver]鏃犳晥鐨勬弿杩扮绱㈠紩
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.login_jsp._jspService(login_jsp.java:123)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.jspdev.ch8.EncodingFilter.doFilter(EncodingFilter.java:36)
root cause
java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]鏃犳晥鐨勬弿杩扮绱㈠紩
sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958)
sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)
sun.jdbc.odbc.JdbcOdbc.SQLGetDataString(JdbcOdbc.java:3908)
sun.jdbc.odbc.JdbcOdbcResultSet.getDataString(JdbcOdbcResultSet.java:5702)
sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:356)
sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:413)
org.apache.jsp.login_jsp._jspService(login_jsp.java:97)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.jspdev.ch8.EncodingFilter.doFilter(EncodingFilter.java:36)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
--------------------------------------------------------------------------------
Apache Tomcat/5.0.28
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: [Microsoft][ODBC SQL Server Driver]鏃犳晥鐨勬弿杩扮绱㈠紩
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.login_jsp._jspService(login_jsp.java:123)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.jspdev.ch8.EncodingFilter.doFilter(EncodingFilter.java:36)
root cause
java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]鏃犳晥鐨勬弿杩扮绱㈠紩
sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958)
sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)
sun.jdbc.odbc.JdbcOdbc.SQLGetDataString(JdbcOdbc.java:3908)
sun.jdbc.odbc.JdbcOdbcResultSet.getDataString(JdbcOdbcResultSet.java:5702)
sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:356)
sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:413)
org.apache.jsp.login_jsp._jspService(login_jsp.java:97)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.jspdev.ch8.EncodingFilter.doFilter(EncodingFilter.java:36)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
--------------------------------------------------------------------------------
Apache Tomcat/5.0.28
#39
statement.execute("update user_info set userLogCount="+count+",userLastLogTime='"+sqltime+"' where userId='" + id +"'");
鎵ц杩欏彞鏃舵湁闂鍚?nbsp;
鍓嶉潰浣犱笉鏄?nbsp;statement.close() 浜嗗悧
鎵ц杩欏彞鏃舵湁闂鍚?nbsp;
鍓嶉潰浣犱笉鏄?nbsp;statement.close() 浜嗗悧
#40
椋炴€濋偅鏈琷sp涔︿笂鐨勪唬鐮佹病鏈夎兘鎴愬姛鐨?鏈€濂借嚜宸变竴姝ヤ竴姝ュ仛.閭f湰涔﹀彧鑳藉仛涓哄弬鑰?
#41
閭d笁涓枃浠舵斁涓€濂楀埌\jdk\jre\lib\ext涓嬮潰锛岃繕鏈夋祴璇曟椂鏈€濂藉皯鍐欐敞閲婏紝鍚﹀垯鏈夊彲鑳介亣鍒板啿绐侊紝锛堝ぉ鍙€滆锛岃繖绉嶉棶棰樹亢閬囪杩囷級銆傛垜鐨勯┍鍔ㄦ斁鍒皌omcat閲屾牴鏈笉琛岋紝鎴戜篃涓嶇煡閬撲负浠€涔堛€?
#42
鍚屾劅鍟婏紝鎴戝氨鏄敤椋炴€濈浜岀増鍟婏紝瑙夌殑濂藉浠g爜閿欙紵
#43
锛滐紞锛嶏紞锛嶏紞锛嶏紞锛嶏紞锛嶏紞锛嶏紞锛嶉珮鎵嬬湅杩囨潵锛?nbsp;鑳戒笉鑳芥悶瀹氳繖涓紵
http://community.csdn.net/Expert/topic/3472/3472337.xml?temp=.2961847
http://community.csdn.net/Expert/topic/3472/3472337.xml?temp=.2961847
#44
棣栧厛璺熶綘璇翠竴鐐?
鍦╯ql server 2000涓? 濡傛灉浣犳槸鐢ㄧ櫥闄嗙郴缁熺殑甯愬彿鍘绘墦寮€鏁版嵁搴撶殑鏄笉琛岀殑,浣犲憜浠ユ墦寮€鏄洜涓虹殑浣犳暟鎹簱瓒呯骇鐢ㄦ埛sa娌℃湁璁剧疆瀵嗙爜,鎵€浠ヤ綘鍙互鎵撳紑.浣嗘槸鍦ㄧ敤ODBC鐨勬椂鍊欏氨涓嶈浜?瀹冭姹備綘杈撳叆瀵嗙爜,鎴戜互鍓嶈瘯杩?鏄笉琛岀殑.鐜板湪娌¤瀹?鎵€浠ュ氨涓嶇煡閬撲簡,涓嶇煡閬撴湁娌℃湁浜鸿瘯杩囨垚鍔熶簡鐨?
浣嗘槸鍦╯ql server 2000涓張鏈夐偅涓€椤?鍙互鐢ㄧ櫥闄嗙郴缁熺殑甯愬彿鍘荤櫥闄嗘暟鎹簱.閭h鍦ㄦ暟鎹簱涓仛鐩稿簲鐨勮缃墠鍙互.涓嶈缃槸涓嶈浜?
鐧婚檰绯荤粺鐨勫笎鍙峰拰鐧婚檰鏁版嵁搴撶殑甯愬彿鏄袱鍥炰簨,鏄笉涓€鏍风殑.SQL Server 2000鐨勮秴绾х敤鎴峰悕鏄痵a ,瀹冪殑鍚嶅瓧鏄笉鑳芥洿鏀圭殑.灏辫薄windows鐨刟dministrator甯愬彿涓€鏍?nbsp;(unix涓槸root).
涓嬮潰鎴戠粰涓€涓狾DBC-JDBC鐨勪緥瀛愬亣璁句綘鍏堝湪"鎺у埗闈㈡澘"涓殑"绠$悊宸ュ叿"涓殑"ODBC鏁版嵁婧?涓繁缁忓缓浜嗕竴涓悕瀛椾负"DataBase"鐨?绯荤粺DNS鏁版嵁婧?.瀹冪殑鐢ㄦ埛鍚嶄负"test",瀵嗙爜涔熶负"test".鍋囪瀹冭繛鎺ョ殑鏄竴涓猘ccess,瀹冨叾涓殑鏁版嵁搴撶殑鍚嶅瓧涓?company",鍏朵腑鏈変竴涓〃鍚嶅瓧涓?employer".
import java.sql.*;
public class DatabaseProductName
{
public static void main(String[] args)
{
Connection con;
Statement stat;
DatabaseMetaData meta;
ResultSet set,info,res;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch (ClassNotFoundException e)
{
System.out.println("Load Driver exception ->"+e);
}
try
{
con=DriverManager.getConnection("jdbc:odbc:DataBase","test","test");
meta=con.getMetaData();
System.out.println("getDatabaseProductName()->"+meta.getDatabaseProductName());
System.out.println("getSchemaTerm() ->"+meta.getSchemaTerm() );
System.out.println("getURL() ->"+meta.getURL() );
System.out.println("getUserName() ->"+meta.getUserName() );
set=meta.getCatalogs();
while (set.next())
{
System.out.println("TABLE_SCHEM ->"+set.getString(1));
}
String type[]={"TABLE"};
String column[]={"TABLE_CAT","TABLE_SCHEM","TABLE_NAME","TABLE_TYPE","REMARKS"};
info=meta.getTables(null,null,"%",type);
ResultSetMetaData me=info.getMetaData();
for (int i=1;i<=me.getColumnCount();i++)
System.out.println(me.getColumnName(i));
while (info.next())
{
for (int i=1;i<=5;i++)
System.out.println(column[i-1]+"<----->"+info.getString(i));
System.out.println();
}
}
catch(SQLException e)
{
System.out.println("SQLException ->"+e);
}//ÉÏÃæµÄÕâЩ¶¼ÊÇһЩµÃµ½Êý¾Ý¿âµÄÐÅÏ¢µÄ,Äã¿ÉÒÔ²»¿´.ÏÂÃæµÄÊÇÒ»¸öÍ锚ÕûµÄÀý脳Ó
try
{
stat=con.createStatement();
res=stat.executeQuery("select * from employer");
while (res.next())
{
System.out.println(res.getString("name")); //name ÊÇ卤铆employerÖеÄÒ»ÁÐ
System.out.println(res.getInt("age")); //age ÊÇ卤铆employerÖеÄÒ»ÁÐ
.......
}
}
catch (SQLException e)
{
System.out.pintln(e);
}
finally
{
try
{
if (con!=null)
con.close();
}
catch (SQLException e)
{
System.out.println("close exception "+e);
}
}
}
}
鍦╯ql server 2000涓? 濡傛灉浣犳槸鐢ㄧ櫥闄嗙郴缁熺殑甯愬彿鍘绘墦寮€鏁版嵁搴撶殑鏄笉琛岀殑,浣犲憜浠ユ墦寮€鏄洜涓虹殑浣犳暟鎹簱瓒呯骇鐢ㄦ埛sa娌℃湁璁剧疆瀵嗙爜,鎵€浠ヤ綘鍙互鎵撳紑.浣嗘槸鍦ㄧ敤ODBC鐨勬椂鍊欏氨涓嶈浜?瀹冭姹備綘杈撳叆瀵嗙爜,鎴戜互鍓嶈瘯杩?鏄笉琛岀殑.鐜板湪娌¤瀹?鎵€浠ュ氨涓嶇煡閬撲簡,涓嶇煡閬撴湁娌℃湁浜鸿瘯杩囨垚鍔熶簡鐨?
浣嗘槸鍦╯ql server 2000涓張鏈夐偅涓€椤?鍙互鐢ㄧ櫥闄嗙郴缁熺殑甯愬彿鍘荤櫥闄嗘暟鎹簱.閭h鍦ㄦ暟鎹簱涓仛鐩稿簲鐨勮缃墠鍙互.涓嶈缃槸涓嶈浜?
鐧婚檰绯荤粺鐨勫笎鍙峰拰鐧婚檰鏁版嵁搴撶殑甯愬彿鏄袱鍥炰簨,鏄笉涓€鏍风殑.SQL Server 2000鐨勮秴绾х敤鎴峰悕鏄痵a ,瀹冪殑鍚嶅瓧鏄笉鑳芥洿鏀圭殑.灏辫薄windows鐨刟dministrator甯愬彿涓€鏍?nbsp;(unix涓槸root).
涓嬮潰鎴戠粰涓€涓狾DBC-JDBC鐨勪緥瀛愬亣璁句綘鍏堝湪"鎺у埗闈㈡澘"涓殑"绠$悊宸ュ叿"涓殑"ODBC鏁版嵁婧?涓繁缁忓缓浜嗕竴涓悕瀛椾负"DataBase"鐨?绯荤粺DNS鏁版嵁婧?.瀹冪殑鐢ㄦ埛鍚嶄负"test",瀵嗙爜涔熶负"test".鍋囪瀹冭繛鎺ョ殑鏄竴涓猘ccess,瀹冨叾涓殑鏁版嵁搴撶殑鍚嶅瓧涓?company",鍏朵腑鏈変竴涓〃鍚嶅瓧涓?employer".
import java.sql.*;
public class DatabaseProductName
{
public static void main(String[] args)
{
Connection con;
Statement stat;
DatabaseMetaData meta;
ResultSet set,info,res;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch (ClassNotFoundException e)
{
System.out.println("Load Driver exception ->"+e);
}
try
{
con=DriverManager.getConnection("jdbc:odbc:DataBase","test","test");
meta=con.getMetaData();
System.out.println("getDatabaseProductName()->"+meta.getDatabaseProductName());
System.out.println("getSchemaTerm() ->"+meta.getSchemaTerm() );
System.out.println("getURL() ->"+meta.getURL() );
System.out.println("getUserName() ->"+meta.getUserName() );
set=meta.getCatalogs();
while (set.next())
{
System.out.println("TABLE_SCHEM ->"+set.getString(1));
}
String type[]={"TABLE"};
String column[]={"TABLE_CAT","TABLE_SCHEM","TABLE_NAME","TABLE_TYPE","REMARKS"};
info=meta.getTables(null,null,"%",type);
ResultSetMetaData me=info.getMetaData();
for (int i=1;i<=me.getColumnCount();i++)
System.out.println(me.getColumnName(i));
while (info.next())
{
for (int i=1;i<=5;i++)
System.out.println(column[i-1]+"<----->"+info.getString(i));
System.out.println();
}
}
catch(SQLException e)
{
System.out.println("SQLException ->"+e);
}//ÉÏÃæµÄÕâЩ¶¼ÊÇһЩµÃµ½Êý¾Ý¿âµÄÐÅÏ¢µÄ,Äã¿ÉÒÔ²»¿´.ÏÂÃæµÄÊÇÒ»¸öÍ锚ÕûµÄÀý脳Ó
try
{
stat=con.createStatement();
res=stat.executeQuery("select * from employer");
while (res.next())
{
System.out.println(res.getString("name")); //name ÊÇ卤铆employerÖеÄÒ»ÁÐ
System.out.println(res.getInt("age")); //age ÊÇ卤铆employerÖеÄÒ»ÁÐ
.......
}
}
catch (SQLException e)
{
System.out.pintln(e);
}
finally
{
try
{
if (con!=null)
con.close();
}
catch (SQLException e)
{
System.out.println("close exception "+e);
}
}
}
}
#45
涓嶅ソ鎰忔€濆垰鎵嶇矘璐翠唬鐮佸嚭浜嗙偣闂,閲嶆柊绮樹竴娆?
import java.sql.*;
public class DatabaseProductName
{
public static void main(String[] args)
{
Connection con;
Statement stat;
DatabaseMetaData meta;
ResultSet set,info,res;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch (ClassNotFoundException e)
{
System.out.println("Load Driver exception ->"+e);
}
try
{
con=DriverManager.getConnection("jdbc:odbc:DataBase","test","test");
meta=con.getMetaData();
System.out.println("getDatabaseProductName()->"+meta.getDatabaseProductName());
System.out.println("getSchemaTerm() ->"+meta.getSchemaTerm() );
System.out.println("getURL() ->"+meta.getURL() );
System.out.println("getUserName() ->"+meta.getUserName() );
set=meta.getCatalogs();
while (set.next())
{
System.out.println("TABLE_SCHEM ->"+set.getString(1));
}
String type[]={"TABLE"};
String column[]={"TABLE_CAT","TABLE_SCHEM","TABLE_NAME","TABLE_TYPE","REMARKS"};
info=meta.getTables(null,null,"%",type);
ResultSetMetaData me=info.getMetaData();
for (int i=1;i<=me.getColumnCount();i++)
System.out.println(me.getColumnName(i));
while (info.next())
{
for (int i=1;i<=5;i++)
System.out.println(column[i-1]+"<----->"+info.getString(i));
System.out.println();
}
}
catch(SQLException e)
{
System.out.println("SQLException ->"+e);
}//杩欎笂闈㈢殑浣犲彲浠ヤ笉鐪?瀹冩槸寰楀埌涓€涓暟鎹簱鐨勪竴浜涗俊鎭?涓嬮潰鐨勬槸涓€涓畬鏁寸殑渚嬪瓙.
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch (ClassNotFoundException e)
{
System.out.println("Load Driver exception ->"+e);
} //杩欎釜try--catch鍙互涓嶈,鍥犱负鏈€涓婇潰鐨?鏀惧湪杩欓噷鏄兂鎶婁笅闈㈢殑鍋氫负涓€涓畬鏁寸殑渚嬪瓙,鏂逛究浣犺鐪?
try
{
stat=con.createStatement();
res=stat.executeQuery("select * from employer");
while (res.next())
{
System.out.println(res.getString("name")); //name ÊÇ卤铆employerÖеÄÒ»ÁÐ
System.out.println(res.getInt("age")); //age ÊÇ卤铆employerÖеÄÒ»ÁÐ
.......
}
}
catch (SQLException e)
{
System.out.pintln(e);
}
finally
{
try
{
if (con!=null)
con.close();
}
catch (SQLException e)
{
System.out.println("close exception "+e);
}
}
}
}
import java.sql.*;
public class DatabaseProductName
{
public static void main(String[] args)
{
Connection con;
Statement stat;
DatabaseMetaData meta;
ResultSet set,info,res;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch (ClassNotFoundException e)
{
System.out.println("Load Driver exception ->"+e);
}
try
{
con=DriverManager.getConnection("jdbc:odbc:DataBase","test","test");
meta=con.getMetaData();
System.out.println("getDatabaseProductName()->"+meta.getDatabaseProductName());
System.out.println("getSchemaTerm() ->"+meta.getSchemaTerm() );
System.out.println("getURL() ->"+meta.getURL() );
System.out.println("getUserName() ->"+meta.getUserName() );
set=meta.getCatalogs();
while (set.next())
{
System.out.println("TABLE_SCHEM ->"+set.getString(1));
}
String type[]={"TABLE"};
String column[]={"TABLE_CAT","TABLE_SCHEM","TABLE_NAME","TABLE_TYPE","REMARKS"};
info=meta.getTables(null,null,"%",type);
ResultSetMetaData me=info.getMetaData();
for (int i=1;i<=me.getColumnCount();i++)
System.out.println(me.getColumnName(i));
while (info.next())
{
for (int i=1;i<=5;i++)
System.out.println(column[i-1]+"<----->"+info.getString(i));
System.out.println();
}
}
catch(SQLException e)
{
System.out.println("SQLException ->"+e);
}//杩欎笂闈㈢殑浣犲彲浠ヤ笉鐪?瀹冩槸寰楀埌涓€涓暟鎹簱鐨勪竴浜涗俊鎭?涓嬮潰鐨勬槸涓€涓畬鏁寸殑渚嬪瓙.
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch (ClassNotFoundException e)
{
System.out.println("Load Driver exception ->"+e);
} //杩欎釜try--catch鍙互涓嶈,鍥犱负鏈€涓婇潰鐨?鏀惧湪杩欓噷鏄兂鎶婁笅闈㈢殑鍋氫负涓€涓畬鏁寸殑渚嬪瓙,鏂逛究浣犺鐪?
try
{
stat=con.createStatement();
res=stat.executeQuery("select * from employer");
while (res.next())
{
System.out.println(res.getString("name")); //name ÊÇ卤铆employerÖеÄÒ»ÁÐ
System.out.println(res.getInt("age")); //age ÊÇ卤铆employerÖеÄÒ»ÁÐ
.......
}
}
catch (SQLException e)
{
System.out.pintln(e);
}
finally
{
try
{
if (con!=null)
con.close();
}
catch (SQLException e)
{
System.out.println("close exception "+e);
}
}
}
}
#46
杩樻湁闂鐨勮瘽.鍔犳垜msn鍚?rogerliu@mango.cc
#1
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling
this request.
exception
javax.servlet.ServletException: [Microsoft][SQLServer 2000 Driver for JDBC]Error
establishing socket.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException
(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException
(PageContextImpl.java:758)
org.apache.jsp.login_jsp._jspService(login_jsp.java:125)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.jspdev.ch8.EncodingFilter.doFilter(EncodingFilter.java:36)
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(DriverManager.java:512)
java.sql.DriverManager.getConnection(DriverManager.java:171)
org.apache.jsp.login_jsp._jspService(login_jsp.java:81)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.jspdev.ch8.EncodingFilter.doFilter(EncodingFilter.java:36)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
--------------------------------------------------------------------------------
Apache Tomcat/5.0.28
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling
this request.
exception
javax.servlet.ServletException: [Microsoft][SQLServer 2000 Driver for JDBC]Error
establishing socket.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException
(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException
(PageContextImpl.java:758)
org.apache.jsp.login_jsp._jspService(login_jsp.java:125)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.jspdev.ch8.EncodingFilter.doFilter(EncodingFilter.java:36)
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(DriverManager.java:512)
java.sql.DriverManager.getConnection(DriverManager.java:171)
org.apache.jsp.login_jsp._jspService(login_jsp.java:81)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.jspdev.ch8.EncodingFilter.doFilter(EncodingFilter.java:36)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
--------------------------------------------------------------------------------
Apache Tomcat/5.0.28
#2
寤虹珛濂楁帴瀛楅敊,濂借薄鏄綉缁滈敊璇?
#3
鏁版嵁搴撻┍鍔ㄧ▼搴忔湁闂銆傛病鏈夋垚鍔熷缓绔嬫暟鎹簱杩炴帴銆?
#4
閭h浠€涔堝仛鍟婏紝鎴戞槸鎶奙icrosoft SQL Server 2000 Driver for JDBC瑁呭湪C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC涓嬬殑锛岃兘涓嶈兘缁欎釜鍏蜂綋鐨勮娉曞悧锛?
#5
杩樺ソ浜嗭紝鎴戠幇鍦ㄨ繕閮戒笉鐭ラ亾浠€涔堟槸杩炴帴姹?
#6
鏁版嵁搴搖rl鐨勭鍙e彿1433鏄惁姝g‘鍛紵鎶?27.0.0.1鎹㈡垚localhost鎴栬€呬綘鏈哄櫒鐨処P璇曚竴涓嬨€?
#7
鏁版嵁搴撻┍鍔ㄧ殑3JAR鏂囦欢鍔犺浇浜嗘病锛?
灏戜竴涓笉琛?
灏戜竴涓笉琛?
#8
鎴戞妸杩檓ssqlserver 锛?nbsp;msbase锛?nbsp;msutil杩欎笁涓枃浠堕兘鎸庡埌浜咰:\jakarta-tomcat-5.0.28\jakarta-tomcat-5.0.28\common\lib鐩笅浜嗐€?
#9
楂樻墜甯府灏忓紵鍚э紝鎴戠幇鍦ㄥ緢鎬ュ晩锛?
鎴戝疄鎵炬槸鎵句笉鍒颁粈涔堝師鍥犱簡锛屼笉鐭ラ亾閿欏湪鍝?nbsp;閲屼簡锛孧icrosoft SQL Server 2000 Driver for JDBC鎴戜篃瑁呬簡锛屼笁涓枃浠舵垜涔熸寧鍒颁簡C:\jakarta-tomcat-5.0.28\jakarta-tomcat-5.0.28\common\lib鐩笅浜嗐€傚氨鏄竴鐩磋繍琛屼笉琛屽晩锛侊紒
鎴戝疄鎵炬槸鎵句笉鍒颁粈涔堝師鍥犱簡锛屼笉鐭ラ亾閿欏湪鍝?nbsp;閲屼簡锛孧icrosoft SQL Server 2000 Driver for JDBC鎴戜篃瑁呬簡锛屼笁涓枃浠舵垜涔熸寧鍒颁簡C:\jakarta-tomcat-5.0.28\jakarta-tomcat-5.0.28\common\lib鐩笅浜嗐€傚氨鏄竴鐩磋繍琛屼笉琛屽晩锛侊紒
#10
hao濂藉儚鏄病鏈夊0鏄庨┍鍔ㄥ憖锛屼笉鐭ヤ綘鐢ㄧ殑鏄痵qlserver杩樻槸浠€涔?
#11
鎴戠敤鐨勬槸sqlserver2000 杩欎釜瑕佷笉瑕佽缃甇DBC鏁版嵁婧愬憿锛?
#12
鎶婅繖mssqlserver 锛?nbsp;msbase锛?nbsp;msutil杩欎笁涓枃浠舵斁鍒皐ebapp涓嬬殑WEB-INF/LIB涓嬭竟璇曡瘯锛?
#13
鏁版嵁搴撻┍鍔ㄧ殑闂鍛€锛?
#14
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
浣犲ソ鍍忓皯鍐欎簡涓滆タ鍟婏紒锛侊紒锛?
浣犲ソ鍍忓皯鍐欎簡涓滆タ鍟婏紒锛侊紒锛?
#15
浣犲皯鍐欎簡.newInstance()
#16
鏈夊晩锛屾垜鎶婅繖浜涘叏鏀惧湪include.inc閲岄潰浜?
鍒板簳閿欏湪閭i噷锛?
鍒板簳閿欏湪閭i噷锛?
#17
copy杩涘幓鍚庯紝閲嶅惎杩囦簡涔堬紵
#18
閮借瘯杩囦簡锛屽ぇ瀹惰鐨勬垜閮借瘯杩囦簡锛屽氨鏄笉鐭ラ亾浠€涔堝姙鍟?
浼氫笉浼氳窡鏁版嵁搴撴斁鐨勪綅缃湁鍏崇郴鍟?
浼氫笉浼氳窡鏁版嵁搴撴斁鐨勪綅缃湁鍏崇郴鍟?
#19
鏁版嵁搴撶殑鐢ㄦ埛鍚嶏紝瀵嗙爜閮戒负绌轰箞锛?
#20
鏄晩锛屾垜鍦ㄦ寜瑁匰QLserver2000鏃跺氨娌℃湁璁剧敤鎴峰悕鍜屽瘑鐮佹墍浠ユ垜璁や负搴旀槸绌虹殑鍚э紒
#21
浼氱殑甯垜涓€涓嬪惂锛?
瑙e喅绔嬭鍏冲笎
瑙e喅绔嬭鍏冲笎
#22
楂樻墜鍟婏紝璺眰鍟?
#23
浣犵殑杩炴帴鏁版嵁搴撶殑鐢ㄦ埛鍚嶄负绌猴紝杩欐槸涓嶈鐨勶紝鑰屼笖SQL銆€SERVER涔熶笉鏀寔绌虹敤鎴峰悕鐨勩€傜敤JDBC杩炴帴SQL銆€SERVER鐨勬椂鍊欏ソ璞$敤鎴峰悕鍜屽瘑鐮佷笉鑳戒负绌虹殑锛岀敤ODBC鐨勬椂鍊橲QL銆€SEVER灏变笉鑳芥湁绌哄瘑鐮佺殑锛屽惁鍒欒繛涓嶄笂鐨勩€備綘鍏堝啓涓€涓繛鎺ユ暟鎹簱鐨勬祴璇曠▼搴忚瘯璇曞彲椐e彲浠ョ敤绌虹殑瀵嗙爜鐨勩€傜湅鐢ㄦ埛鍚嶅拰瀵嗙爜鍙笉鍙负绌恒€?
#24
浣犲湪鎸夎SQLserver2000鏃跺氨娌℃湁璁剧敤鎴峰悕鍜屽瘑鐮侊紝骞朵笉鑳借涓哄簲鏄┖鐨勶紝SQL銆€SERVER鐨勯粯璁ょ敤鎴峰悕鏄痵a,骞朵笉鏄病鏈夌敤鎴峰悕锛屾墍浠ヤ綘鐨勭▼搴忎腑鐨刄SER鐨勫€艰鏄痵a,鍙槸浣犳病鏈夊瘑鐮侊紝瀹冪殑鍊兼墠涓虹┖銆?
#25
鏈€鍚庢槸鍦⊿QL銆€SERVER涓暟鎹簱鐨勫睘鎬т腑涓簊a鐢ㄦ埛璁剧疆涓€涓瘑鐮侊紝瑕佸畨鍏ㄤ竴浜涖€?
#26
drugon(personal锛夛細鎴戠幇宸叉妸鐢ㄦ埛鍚嶈涓簎ser鍜屽瘑鐮佷负user鍙槸杩欐牱杩樻槸涓嶈鍟婏紒
#27
浣犵湅涓€涓嬫垜鍐欑殑SQLSERVER2000鐨勮繛鎺ワ紝濡傛灉鏄繛鎺ョ殑闂锛屼綘鍏堟妸杩炴帴鍐欏埌BEAN鎴栨槸鐩存帴鍐欏埌JSP椤甸潰閲屽幓璇曚竴璇曪紝鎶婁綘鐨勮繛鎺ラ儴鍒嗘崲鎴愭垜鐨勫氨鑲畾娌℃湁闂浜嗭紙鎴戞槸鍐欏湪BEAN閲岄潰鐨勶級
public Connection connect() throws Exception {
try {
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver")
.newInstance();
System.out.println("jdbc loading....");
String url = "jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=cctest";
String user = "sa";
String password = "manager";
con = DriverManager.getConnection(url, user, password);
return con;
} catch (Exception e) {
error = "EXC:Connection to database was lost";
throw new Exception(error);
}
}
public Connection connect() throws Exception {
try {
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver")
.newInstance();
System.out.println("jdbc loading....");
String url = "jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=cctest";
String user = "sa";
String password = "manager";
con = DriverManager.getConnection(url, user, password);
return con;
} catch (Exception e) {
error = "EXC:Connection to database was lost";
throw new Exception(error);
}
}
#28
杩欐牱鍐欑殑璺熼偅鏍锋湁鍏风殑鐨勫尯鍒悧锛?
#29
鎴戝師浠ヤ负鏄粈涔堥敊浜嗭紝鎴戝氨鍐嶅彟鍐欎竴涓紝鏁版嵁搴撹繛鎺ワ紝鍙槸涔熶竴鏍峰嚭鐜颁笂闈㈢殑閭f牱鍑洪敊鐨勬彁绀猴紵锛?
#30
涓嬭浇SQL Server 2000 Driver for JDBC Service Pack 3
http://www.microsoft.com/downloads/details.aspx?FamilyId=07287B11-0502-461A-B138-2AA54BFDC03A&displaylang=en
涓嬩簡瑁呬笂鐪嬬湅
http://www.microsoft.com/downloads/details.aspx?FamilyId=07287B11-0502-461A-B138-2AA54BFDC03A&displaylang=en
涓嬩簡瑁呬笂鐪嬬湅
#31
妫€鏌ラ槻鐏锛宨p鍦板潃锛屽鏋滈兘娌¢棶棰橀偅灏辨槸鎿嶄綔绯荤粺鐨勪簨鍎夸簡
濡傛灉鏄痻p(sp1)浠ヤ笂鐨勭増鏈紝Service Pack 3琛ヤ竵瑁呬笂锛岃涓婁簡鍙兘浼氬ソ浣匡紝win2000浠ヤ笂鐨勬搷浣滅郴缁熻浜唖ql2000涓€鑸兘浼氬嚭鐜拌繖绉嶉棶棰橈紝褰撳垵杩欎釜闂鎶樼(浜嗘垜涓ゅぉ涓ゅ锛堟睏锛夛紒寤鸿浣犳渶濂借xp(sp1鐗?鐨勶紝杩欐槸缁堟瀬瑙e喅鍔炴硶锛侊紒锛佸墠鎻愭槸浣犺瀹宻p3琛ヤ竵鍚庝粛鐒惰繛鎺ヤ笉涓?
濡傛灉鏄痻p(sp1)浠ヤ笂鐨勭増鏈紝Service Pack 3琛ヤ竵瑁呬笂锛岃涓婁簡鍙兘浼氬ソ浣匡紝win2000浠ヤ笂鐨勬搷浣滅郴缁熻浜唖ql2000涓€鑸兘浼氬嚭鐜拌繖绉嶉棶棰橈紝褰撳垵杩欎釜闂鎶樼(浜嗘垜涓ゅぉ涓ゅ锛堟睏锛夛紒寤鸿浣犳渶濂借xp(sp1鐗?鐨勶紝杩欐槸缁堟瀬瑙e喅鍔炴硶锛侊紒锛佸墠鎻愭槸浣犺瀹宻p3琛ヤ竵鍚庝粛鐒惰繛鎺ヤ笉涓?
#32
鎴戠敤鐨勬槸XP(SP2)锛屽ソ鐨勶紝鎴戣瘯涓嬬湅琛屼笉琛岋紵
#33
鍚勪綅澶у摜鎴戣瘯浜嗚繕鏄笉琛岋紵
#34
浼拌鏄綘鐨勬暟鎹簱椹卞姩娌″紕濂?
#35
搴旇涓嶆槸椹卞姩鐨勯棶棰?
浣犵殑sa鐢ㄦ埛鐨勫瘑鐮佹槸涓嶆槸manager鍛€?
浣犲厛鐢ㄥ瘑鐮佷负manager鐨勭敤鎴穝a鐢∣DBC杩炵殑璇曡瘯鐪?濡傛灉鍙互閭e氨涓嶆槸椹卞姩鐨勯棶棰?鍙兘鏄叾瀹冪殑鍘熷洜,鎴栬€呬綘鎶妔p2鍖呭嵏鎺夎瘯璇?浠ュ墠濂借薄鐪嬪埌鍒汉涔熷嚭鐜拌繃杩欐牱鐨勯棶棰?
浣犵殑sa鐢ㄦ埛鐨勫瘑鐮佹槸涓嶆槸manager鍛€?
浣犲厛鐢ㄥ瘑鐮佷负manager鐨勭敤鎴穝a鐢∣DBC杩炵殑璇曡瘯鐪?濡傛灉鍙互閭e氨涓嶆槸椹卞姩鐨勯棶棰?鍙兘鏄叾瀹冪殑鍘熷洜,鎴栬€呬綘鎶妔p2鍖呭嵏鎺夎瘯璇?浠ュ墠濂借薄鐪嬪埌鍒汉涔熷嚭鐜拌繃杩欐牱鐨勯棶棰?
#36
鎴戣瘯杩囦簡杩樻槸涓嶈銆傛垜鏄敤鎴戠郴缁熺櫥褰曠殑鐢ㄦ埛鐨勫瘑鐮佷綔涓鸿繛鎺ユ暟鎹簱鐨勭殑锛屼笉鐭ラ亾鏄笉鏄繖涓晩锛?
褰撶劧鎴戜篃鐢⊿A鍜岀櫥褰曞瘑鐮佽瘯杩囧氨鏄笉琛屽晩锛佷笉鐭ラ亾鍚勪綅澶у摜浠垜杩欐牱鍋氭槸涓嶆槸鍙互鍟婏紝鎴戞槸涓垵瀛﹁€呬笉鐭ラ亾閿欏湪閭i噷浜?
褰撶劧鎴戜篃鐢⊿A鍜岀櫥褰曞瘑鐮佽瘯杩囧氨鏄笉琛屽晩锛佷笉鐭ラ亾鍚勪綅澶у摜浠垜杩欐牱鍋氭槸涓嶆槸鍙互鍟婏紝鎴戞槸涓垵瀛﹁€呬笉鐭ラ亾閿欏湪閭i噷浜?
#37
drugon(personal) 锛氱敤ODBC濡備綍鍐欎綘鑳藉府鎴戝啓涓€涓垜璇曡瘯鐪嬭兘涓嶈兘杩烇紵
#38
璋㈣阿澶у鐨勶紝鎻愮ず鍟婏紝鎴戞妸椹卞姩绋嬪簭鏀规垚JDBC-ODBC杩炴帴灏卞彲浠ヤ簡锛屽彧鏄綋鎴戣緭鍏ョ敤鎴峰悕锛屽杈撳叆閿欏氨鍙槸杈惧埌瑕佹眰锛屼絾鏄緭鍏ellking涔熷氨鏄緭鍏ユ纭殑鐢ㄦ埛鍚嶄笌瀵嗙爜鏃讹紝灏辨彁绀哄涓嬮敊璇紝涓嶇煡閬撻敊鍦ㄥ摢 閲岋紵
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: [Microsoft][ODBC SQL Server Driver]鏃犳晥鐨勬弿杩扮绱㈠紩
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.login_jsp._jspService(login_jsp.java:123)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.jspdev.ch8.EncodingFilter.doFilter(EncodingFilter.java:36)
root cause
java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]鏃犳晥鐨勬弿杩扮绱㈠紩
sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958)
sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)
sun.jdbc.odbc.JdbcOdbc.SQLGetDataString(JdbcOdbc.java:3908)
sun.jdbc.odbc.JdbcOdbcResultSet.getDataString(JdbcOdbcResultSet.java:5702)
sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:356)
sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:413)
org.apache.jsp.login_jsp._jspService(login_jsp.java:97)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.jspdev.ch8.EncodingFilter.doFilter(EncodingFilter.java:36)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
--------------------------------------------------------------------------------
Apache Tomcat/5.0.28
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: [Microsoft][ODBC SQL Server Driver]鏃犳晥鐨勬弿杩扮绱㈠紩
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.login_jsp._jspService(login_jsp.java:123)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.jspdev.ch8.EncodingFilter.doFilter(EncodingFilter.java:36)
root cause
java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]鏃犳晥鐨勬弿杩扮绱㈠紩
sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958)
sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)
sun.jdbc.odbc.JdbcOdbc.SQLGetDataString(JdbcOdbc.java:3908)
sun.jdbc.odbc.JdbcOdbcResultSet.getDataString(JdbcOdbcResultSet.java:5702)
sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:356)
sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:413)
org.apache.jsp.login_jsp._jspService(login_jsp.java:97)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.jspdev.ch8.EncodingFilter.doFilter(EncodingFilter.java:36)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
--------------------------------------------------------------------------------
Apache Tomcat/5.0.28
#39
statement.execute("update user_info set userLogCount="+count+",userLastLogTime='"+sqltime+"' where userId='" + id +"'");
鎵ц杩欏彞鏃舵湁闂鍚?nbsp;
鍓嶉潰浣犱笉鏄?nbsp;statement.close() 浜嗗悧
鎵ц杩欏彞鏃舵湁闂鍚?nbsp;
鍓嶉潰浣犱笉鏄?nbsp;statement.close() 浜嗗悧
#40
椋炴€濋偅鏈琷sp涔︿笂鐨勪唬鐮佹病鏈夎兘鎴愬姛鐨?鏈€濂借嚜宸变竴姝ヤ竴姝ュ仛.閭f湰涔﹀彧鑳藉仛涓哄弬鑰?
#41
閭d笁涓枃浠舵斁涓€濂楀埌\jdk\jre\lib\ext涓嬮潰锛岃繕鏈夋祴璇曟椂鏈€濂藉皯鍐欐敞閲婏紝鍚﹀垯鏈夊彲鑳介亣鍒板啿绐侊紝锛堝ぉ鍙€滆锛岃繖绉嶉棶棰樹亢閬囪杩囷級銆傛垜鐨勯┍鍔ㄦ斁鍒皌omcat閲屾牴鏈笉琛岋紝鎴戜篃涓嶇煡閬撲负浠€涔堛€?
#42
鍚屾劅鍟婏紝鎴戝氨鏄敤椋炴€濈浜岀増鍟婏紝瑙夌殑濂藉浠g爜閿欙紵
#43
锛滐紞锛嶏紞锛嶏紞锛嶏紞锛嶏紞锛嶏紞锛嶏紞锛嶉珮鎵嬬湅杩囨潵锛?nbsp;鑳戒笉鑳芥悶瀹氳繖涓紵
http://community.csdn.net/Expert/topic/3472/3472337.xml?temp=.2961847
http://community.csdn.net/Expert/topic/3472/3472337.xml?temp=.2961847
#44
棣栧厛璺熶綘璇翠竴鐐?
鍦╯ql server 2000涓? 濡傛灉浣犳槸鐢ㄧ櫥闄嗙郴缁熺殑甯愬彿鍘绘墦寮€鏁版嵁搴撶殑鏄笉琛岀殑,浣犲憜浠ユ墦寮€鏄洜涓虹殑浣犳暟鎹簱瓒呯骇鐢ㄦ埛sa娌℃湁璁剧疆瀵嗙爜,鎵€浠ヤ綘鍙互鎵撳紑.浣嗘槸鍦ㄧ敤ODBC鐨勬椂鍊欏氨涓嶈浜?瀹冭姹備綘杈撳叆瀵嗙爜,鎴戜互鍓嶈瘯杩?鏄笉琛岀殑.鐜板湪娌¤瀹?鎵€浠ュ氨涓嶇煡閬撲簡,涓嶇煡閬撴湁娌℃湁浜鸿瘯杩囨垚鍔熶簡鐨?
浣嗘槸鍦╯ql server 2000涓張鏈夐偅涓€椤?鍙互鐢ㄧ櫥闄嗙郴缁熺殑甯愬彿鍘荤櫥闄嗘暟鎹簱.閭h鍦ㄦ暟鎹簱涓仛鐩稿簲鐨勮缃墠鍙互.涓嶈缃槸涓嶈浜?
鐧婚檰绯荤粺鐨勫笎鍙峰拰鐧婚檰鏁版嵁搴撶殑甯愬彿鏄袱鍥炰簨,鏄笉涓€鏍风殑.SQL Server 2000鐨勮秴绾х敤鎴峰悕鏄痵a ,瀹冪殑鍚嶅瓧鏄笉鑳芥洿鏀圭殑.灏辫薄windows鐨刟dministrator甯愬彿涓€鏍?nbsp;(unix涓槸root).
涓嬮潰鎴戠粰涓€涓狾DBC-JDBC鐨勪緥瀛愬亣璁句綘鍏堝湪"鎺у埗闈㈡澘"涓殑"绠$悊宸ュ叿"涓殑"ODBC鏁版嵁婧?涓繁缁忓缓浜嗕竴涓悕瀛椾负"DataBase"鐨?绯荤粺DNS鏁版嵁婧?.瀹冪殑鐢ㄦ埛鍚嶄负"test",瀵嗙爜涔熶负"test".鍋囪瀹冭繛鎺ョ殑鏄竴涓猘ccess,瀹冨叾涓殑鏁版嵁搴撶殑鍚嶅瓧涓?company",鍏朵腑鏈変竴涓〃鍚嶅瓧涓?employer".
import java.sql.*;
public class DatabaseProductName
{
public static void main(String[] args)
{
Connection con;
Statement stat;
DatabaseMetaData meta;
ResultSet set,info,res;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch (ClassNotFoundException e)
{
System.out.println("Load Driver exception ->"+e);
}
try
{
con=DriverManager.getConnection("jdbc:odbc:DataBase","test","test");
meta=con.getMetaData();
System.out.println("getDatabaseProductName()->"+meta.getDatabaseProductName());
System.out.println("getSchemaTerm() ->"+meta.getSchemaTerm() );
System.out.println("getURL() ->"+meta.getURL() );
System.out.println("getUserName() ->"+meta.getUserName() );
set=meta.getCatalogs();
while (set.next())
{
System.out.println("TABLE_SCHEM ->"+set.getString(1));
}
String type[]={"TABLE"};
String column[]={"TABLE_CAT","TABLE_SCHEM","TABLE_NAME","TABLE_TYPE","REMARKS"};
info=meta.getTables(null,null,"%",type);
ResultSetMetaData me=info.getMetaData();
for (int i=1;i<=me.getColumnCount();i++)
System.out.println(me.getColumnName(i));
while (info.next())
{
for (int i=1;i<=5;i++)
System.out.println(column[i-1]+"<----->"+info.getString(i));
System.out.println();
}
}
catch(SQLException e)
{
System.out.println("SQLException ->"+e);
}//ÉÏÃæµÄÕâЩ¶¼ÊÇһЩµÃµ½Êý¾Ý¿âµÄÐÅÏ¢µÄ,Äã¿ÉÒÔ²»¿´.ÏÂÃæµÄÊÇÒ»¸öÍ锚ÕûµÄÀý脳Ó
try
{
stat=con.createStatement();
res=stat.executeQuery("select * from employer");
while (res.next())
{
System.out.println(res.getString("name")); //name ÊÇ卤铆employerÖеÄÒ»ÁÐ
System.out.println(res.getInt("age")); //age ÊÇ卤铆employerÖеÄÒ»ÁÐ
.......
}
}
catch (SQLException e)
{
System.out.pintln(e);
}
finally
{
try
{
if (con!=null)
con.close();
}
catch (SQLException e)
{
System.out.println("close exception "+e);
}
}
}
}
鍦╯ql server 2000涓? 濡傛灉浣犳槸鐢ㄧ櫥闄嗙郴缁熺殑甯愬彿鍘绘墦寮€鏁版嵁搴撶殑鏄笉琛岀殑,浣犲憜浠ユ墦寮€鏄洜涓虹殑浣犳暟鎹簱瓒呯骇鐢ㄦ埛sa娌℃湁璁剧疆瀵嗙爜,鎵€浠ヤ綘鍙互鎵撳紑.浣嗘槸鍦ㄧ敤ODBC鐨勬椂鍊欏氨涓嶈浜?瀹冭姹備綘杈撳叆瀵嗙爜,鎴戜互鍓嶈瘯杩?鏄笉琛岀殑.鐜板湪娌¤瀹?鎵€浠ュ氨涓嶇煡閬撲簡,涓嶇煡閬撴湁娌℃湁浜鸿瘯杩囨垚鍔熶簡鐨?
浣嗘槸鍦╯ql server 2000涓張鏈夐偅涓€椤?鍙互鐢ㄧ櫥闄嗙郴缁熺殑甯愬彿鍘荤櫥闄嗘暟鎹簱.閭h鍦ㄦ暟鎹簱涓仛鐩稿簲鐨勮缃墠鍙互.涓嶈缃槸涓嶈浜?
鐧婚檰绯荤粺鐨勫笎鍙峰拰鐧婚檰鏁版嵁搴撶殑甯愬彿鏄袱鍥炰簨,鏄笉涓€鏍风殑.SQL Server 2000鐨勮秴绾х敤鎴峰悕鏄痵a ,瀹冪殑鍚嶅瓧鏄笉鑳芥洿鏀圭殑.灏辫薄windows鐨刟dministrator甯愬彿涓€鏍?nbsp;(unix涓槸root).
涓嬮潰鎴戠粰涓€涓狾DBC-JDBC鐨勪緥瀛愬亣璁句綘鍏堝湪"鎺у埗闈㈡澘"涓殑"绠$悊宸ュ叿"涓殑"ODBC鏁版嵁婧?涓繁缁忓缓浜嗕竴涓悕瀛椾负"DataBase"鐨?绯荤粺DNS鏁版嵁婧?.瀹冪殑鐢ㄦ埛鍚嶄负"test",瀵嗙爜涔熶负"test".鍋囪瀹冭繛鎺ョ殑鏄竴涓猘ccess,瀹冨叾涓殑鏁版嵁搴撶殑鍚嶅瓧涓?company",鍏朵腑鏈変竴涓〃鍚嶅瓧涓?employer".
import java.sql.*;
public class DatabaseProductName
{
public static void main(String[] args)
{
Connection con;
Statement stat;
DatabaseMetaData meta;
ResultSet set,info,res;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch (ClassNotFoundException e)
{
System.out.println("Load Driver exception ->"+e);
}
try
{
con=DriverManager.getConnection("jdbc:odbc:DataBase","test","test");
meta=con.getMetaData();
System.out.println("getDatabaseProductName()->"+meta.getDatabaseProductName());
System.out.println("getSchemaTerm() ->"+meta.getSchemaTerm() );
System.out.println("getURL() ->"+meta.getURL() );
System.out.println("getUserName() ->"+meta.getUserName() );
set=meta.getCatalogs();
while (set.next())
{
System.out.println("TABLE_SCHEM ->"+set.getString(1));
}
String type[]={"TABLE"};
String column[]={"TABLE_CAT","TABLE_SCHEM","TABLE_NAME","TABLE_TYPE","REMARKS"};
info=meta.getTables(null,null,"%",type);
ResultSetMetaData me=info.getMetaData();
for (int i=1;i<=me.getColumnCount();i++)
System.out.println(me.getColumnName(i));
while (info.next())
{
for (int i=1;i<=5;i++)
System.out.println(column[i-1]+"<----->"+info.getString(i));
System.out.println();
}
}
catch(SQLException e)
{
System.out.println("SQLException ->"+e);
}//ÉÏÃæµÄÕâЩ¶¼ÊÇһЩµÃµ½Êý¾Ý¿âµÄÐÅÏ¢µÄ,Äã¿ÉÒÔ²»¿´.ÏÂÃæµÄÊÇÒ»¸öÍ锚ÕûµÄÀý脳Ó
try
{
stat=con.createStatement();
res=stat.executeQuery("select * from employer");
while (res.next())
{
System.out.println(res.getString("name")); //name ÊÇ卤铆employerÖеÄÒ»ÁÐ
System.out.println(res.getInt("age")); //age ÊÇ卤铆employerÖеÄÒ»ÁÐ
.......
}
}
catch (SQLException e)
{
System.out.pintln(e);
}
finally
{
try
{
if (con!=null)
con.close();
}
catch (SQLException e)
{
System.out.println("close exception "+e);
}
}
}
}
#45
涓嶅ソ鎰忔€濆垰鎵嶇矘璐翠唬鐮佸嚭浜嗙偣闂,閲嶆柊绮樹竴娆?
import java.sql.*;
public class DatabaseProductName
{
public static void main(String[] args)
{
Connection con;
Statement stat;
DatabaseMetaData meta;
ResultSet set,info,res;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch (ClassNotFoundException e)
{
System.out.println("Load Driver exception ->"+e);
}
try
{
con=DriverManager.getConnection("jdbc:odbc:DataBase","test","test");
meta=con.getMetaData();
System.out.println("getDatabaseProductName()->"+meta.getDatabaseProductName());
System.out.println("getSchemaTerm() ->"+meta.getSchemaTerm() );
System.out.println("getURL() ->"+meta.getURL() );
System.out.println("getUserName() ->"+meta.getUserName() );
set=meta.getCatalogs();
while (set.next())
{
System.out.println("TABLE_SCHEM ->"+set.getString(1));
}
String type[]={"TABLE"};
String column[]={"TABLE_CAT","TABLE_SCHEM","TABLE_NAME","TABLE_TYPE","REMARKS"};
info=meta.getTables(null,null,"%",type);
ResultSetMetaData me=info.getMetaData();
for (int i=1;i<=me.getColumnCount();i++)
System.out.println(me.getColumnName(i));
while (info.next())
{
for (int i=1;i<=5;i++)
System.out.println(column[i-1]+"<----->"+info.getString(i));
System.out.println();
}
}
catch(SQLException e)
{
System.out.println("SQLException ->"+e);
}//杩欎笂闈㈢殑浣犲彲浠ヤ笉鐪?瀹冩槸寰楀埌涓€涓暟鎹簱鐨勪竴浜涗俊鎭?涓嬮潰鐨勬槸涓€涓畬鏁寸殑渚嬪瓙.
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch (ClassNotFoundException e)
{
System.out.println("Load Driver exception ->"+e);
} //杩欎釜try--catch鍙互涓嶈,鍥犱负鏈€涓婇潰鐨?鏀惧湪杩欓噷鏄兂鎶婁笅闈㈢殑鍋氫负涓€涓畬鏁寸殑渚嬪瓙,鏂逛究浣犺鐪?
try
{
stat=con.createStatement();
res=stat.executeQuery("select * from employer");
while (res.next())
{
System.out.println(res.getString("name")); //name ÊÇ卤铆employerÖеÄÒ»ÁÐ
System.out.println(res.getInt("age")); //age ÊÇ卤铆employerÖеÄÒ»ÁÐ
.......
}
}
catch (SQLException e)
{
System.out.pintln(e);
}
finally
{
try
{
if (con!=null)
con.close();
}
catch (SQLException e)
{
System.out.println("close exception "+e);
}
}
}
}
import java.sql.*;
public class DatabaseProductName
{
public static void main(String[] args)
{
Connection con;
Statement stat;
DatabaseMetaData meta;
ResultSet set,info,res;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch (ClassNotFoundException e)
{
System.out.println("Load Driver exception ->"+e);
}
try
{
con=DriverManager.getConnection("jdbc:odbc:DataBase","test","test");
meta=con.getMetaData();
System.out.println("getDatabaseProductName()->"+meta.getDatabaseProductName());
System.out.println("getSchemaTerm() ->"+meta.getSchemaTerm() );
System.out.println("getURL() ->"+meta.getURL() );
System.out.println("getUserName() ->"+meta.getUserName() );
set=meta.getCatalogs();
while (set.next())
{
System.out.println("TABLE_SCHEM ->"+set.getString(1));
}
String type[]={"TABLE"};
String column[]={"TABLE_CAT","TABLE_SCHEM","TABLE_NAME","TABLE_TYPE","REMARKS"};
info=meta.getTables(null,null,"%",type);
ResultSetMetaData me=info.getMetaData();
for (int i=1;i<=me.getColumnCount();i++)
System.out.println(me.getColumnName(i));
while (info.next())
{
for (int i=1;i<=5;i++)
System.out.println(column[i-1]+"<----->"+info.getString(i));
System.out.println();
}
}
catch(SQLException e)
{
System.out.println("SQLException ->"+e);
}//杩欎笂闈㈢殑浣犲彲浠ヤ笉鐪?瀹冩槸寰楀埌涓€涓暟鎹簱鐨勪竴浜涗俊鎭?涓嬮潰鐨勬槸涓€涓畬鏁寸殑渚嬪瓙.
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch (ClassNotFoundException e)
{
System.out.println("Load Driver exception ->"+e);
} //杩欎釜try--catch鍙互涓嶈,鍥犱负鏈€涓婇潰鐨?鏀惧湪杩欓噷鏄兂鎶婁笅闈㈢殑鍋氫负涓€涓畬鏁寸殑渚嬪瓙,鏂逛究浣犺鐪?
try
{
stat=con.createStatement();
res=stat.executeQuery("select * from employer");
while (res.next())
{
System.out.println(res.getString("name")); //name ÊÇ卤铆employerÖеÄÒ»ÁÐ
System.out.println(res.getInt("age")); //age ÊÇ卤铆employerÖеÄÒ»ÁÐ
.......
}
}
catch (SQLException e)
{
System.out.pintln(e);
}
finally
{
try
{
if (con!=null)
con.close();
}
catch (SQLException e)
{
System.out.println("close exception "+e);
}
}
}
}
#46
杩樻湁闂鐨勮瘽.鍔犳垜msn鍚?rogerliu@mango.cc