JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » Servlet/JSP 討論區  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友   
reply to postflat modego to previous topicgo to next topic
本主題所含的標籤
無標籤
作者 請教這個訊息該如何解決...
ChungChuanChen





發文: 8
積分: 0
於 2003-07-06 13:54 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
java.sql.SQLException:
[Microsoft][SQLServer 2000 Driver for JDBC]Error establis socket.

我是在tomcat4.1.24、j2sdk1.4.02的環境下執行,
使用Sql Server 2000 個人版已更新至sp3...

那請問...上述的錯誤訊息是我下列的程式中那裡有問題...
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;

public class GuestInsertMsg extends HttpServlet {
private Connection con = null;
private Statement stmt = null;
private ResultSet rs = null;
private String errorMsg = "";
private String UserName, UserPwd, UserDB;

public void init(ServletConfig config) throws ServletException{
super.init(config);
UserName = config.getInitParameter("user");
UserPwd = config.getInitParameter("pwd");
UserDB = config.getInitParameter("dbnm");
try {
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection con = DriverManager.getConnection(
"jdbc:microsoft:sqlserver://localhost:1433;DatabaseName="+UserDB+";User="+UserName+";Password="+UserPwd);
} catch (ClassNotFoundException cnfe) {
errorMsg = "沒找到||||";
} catch ( SQLException sqlex) {
errorMsg = sqlex.toString();
}
}

public void doPost( HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("Big5");
String MsgTitle, MsgContent, CsName, CsEmail, tmp;
MsgTitle = request.getParameter("msgtitle");
MsgContent = request.getParameter("msgcontent");
CsName = request.getParameter("csname");
CsEmail = request.getParameter("csemail");
tmp = "MsgTitle:" + MsgTitle + "<br>" +
"MsgContent:" + MsgContent + "<br>" +
"消費者代號:" + CsName + "<br>" +
"消費者Email:" + CsEmail + "<br>";

PrintWriter output = response.getWriter();
response.setContentType("text/html;charset=Big5");
output.println("<html><head><title>新增信件</title></head><body>");
output.println("錯誤訊息:<br>"+errorMsg+"<br>MsgInfo:"+tmp+"<br>");
output.println("</body></html>");
}
}


reply to postreply to post
話題樹型展開
人氣 標題 作者 字數 發文時間
1978 請教這個訊息該如何解決... ChungChuanChen 2388 2003-07-06 13:54
1640 Re:請教這個訊息該如何解決... koji 54 2003-07-06 16:50
1785 Re:請教這個訊息該如何解決... ChungChuanChen 41 2003-07-06 21:31
2254 Re:請教這個訊息該如何解決... snpshu 50 2003-07-07 00:17
» JWorld@TW »  Servlet/JSP 討論區

reply to postflat modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8