To: dingyuan
不知你是否解決了這個問題,如果解決了,能否告訴我你是使用何種JDBC 嗎?
To: eguy, 斯人,
我現在也要對數據庫做一大文本的處理,我用是text 類型(mssql),主要是存文件字符,
如在網上考貝一段文章存到資料庫。我已對字符做過編碼,bean也編譯通過。但是Tomcat 報如下
錯誤,
Exception Report:
javax.servlet.ServletException
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:481)
at i_00025tranet.manager._0002fintranet_0002fmanager_0002fpostdata_0002ejsppostdata_jsp_23._jspService
(_0002fintranet_0002fmanager_0002fpostdata_0002ejsppostdata_jsp_23.java:161)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
...
Root Cause:
java.lang.NoSuchMethodError
at i_00025tranet.manager._0002fintranet_0002fmanager_0002fpostdata_0002ejsppostdata_jsp_23._jspService
(_0002fintranet_0002fmanager_0002fpostdata_0002ejsppostdata_jsp_23.java:121)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
.....
是否是我的jdbc 沒有某些方法?
我的源代嗎如下:
<jsp:useBean id="workM" scope="page" class="dbpool.JDBCMSSQL" />
<% String Boardid = request.getParameter("boardid");
String Types = request.getParameter("types");
String Author = request.getParameter("author");
String nAuthor = new String(Author.getBytes("big5"),"iso-8859-1");
String Title = request.getParameter("title");
String nTitle = new String(Title.getBytes("big5"),"iso-8859-1");
String Face = request.getParameter("face");
String Texts = request.getParameter("texts");
String nTexts = new String(Texts.getBytes("big5"),"iso-8859-1");
String Linkbox = request.getParameter("linkbox");
if (Linkbox == null) Linkbox="N";
String Linkurl = request.getParameter("linkurl");
if (Linkurl == null) Linkurl="";
Date now = new Date();
String AddDate = DateFormat.getDateInstance().format(now);
String Clicks ="0";
String Returns ="0";
String IsNew = "Y";
String IsDel = "N";
String usql = "INSERT INTO dbo.T_articles(BoardId, Types, Author, Title, " +
" Faces, Clicks, Returns, AddDate, LinkBox , LinkURL, IsNew, IsDel)" +
"VALUES (" + Boardid + "," + Types + ",'" + nAuthor + "','" + nTitle +
"',"+ Face + "," + Clicks + "," + Returns + ",'" + AddDate + "','" +
Linkbox + "','" + Linkurl +"','" + IsNew + "','" + IsDel + "')";
long RS = workM.executeUpdate(usql);
if (RS > 0){
String Tsql = "select max(ids) as maxNo from T_articles";
ResultSet rs1= workM.executeQuery(Tsql);
rs1.next();
Tsql = "update T_articles set texts= ? where ids=" + String.valueOf(rs1.getInt("maxNo"));
out.print(Tsql);
int rev =workM.TextUpdate(Tsql, nTexts);
if (rev > 0) out.print("update data is ok");
workM.CloseTextUpdate();
%>
Bean 如下:
package dbpool ;
import java.sql.* ;
public class JDBCMSSQL{
public String url="jdbc:inetdae:10.28.1.254?Sql7=true";
public String login="sa";
public String password="";
public String ConDB="webdatas";
public ResultSet rs=null;
public ResultSetMetaData resultsMeta =null;
public Connection conn;
public Statement st;
public PreparedStatement stm;
public boolean status;
public String sql;
public int columns;
public long rowcount =0;
public int rcount = 0;
public JDBCMSSQL(){
try{
Class.forName("com.inet.tds.TdsDriver").newInstance();
}
catch(Exception e){
System.err.println("JDBCMSSQL():" + e.getMessage());
}
}
public int TextUpdate(String sql, String x){
try{
DriverManager.setLoginTimeout(10);
conn = DriverManager.getConnection(url,login,password);
conn.setCatalog(ConDB);
stm=conn.prepareStatement(sql);
stm.setString(1,x);
rcount = stm.executeUpdate();
}
catch(SQLException ex){
System.err.println("JDBCMSSQL.TextUpdate.executeUpdate: " + ex.getMessage());
}
return rcount;
}
是為什麼呢?