M
missing_miss
Unregistered / Unconfirmed
GUEST, unregistred user!
我用的是jdk和jswdk的运行环境用sql server的数据库,已经再控制面版中建立了odbc
数据源,我建了一张表单,为message,编写jsp程序调用后出现java.sql.SQLException:
[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name 'message'.
为什么说我的表单非法呢??我的jsp程序如下:(望大虾指点)
<!--view_message.jsp-->
<%@ page import="java.sql.*" %>
<HTML>
<HEAD>
<TITLE> show the message in the table </TITLE>
</HEAD>
<BODY>
<p align="center">所有访客留言</p>
<hr>
<%
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbcdbc:user_db";
Connection con=DriverManager.getConnection(url,"li","781008");
Statement stm=con.createStatement();
ResultSet result=stm.executeQuery("select count(*) from
message");
int message_count=0;
if(result.next())
{
message_count=result.getInt(1);
result.close();
}
if(message_count>0)
{
result=stm.executeQuery("select * from message
order by time desc");
while(result.next())
{
String title=result.getString("title");
String name=result.getString("name");
String mail=result.getString("mail");
Timestamp
time=result.getTimestamp("time");
Date date_time=new
Date(time.getTime());
Time time_time=new
Time(time.getTime());
String
content=result.getString("content");
%>
<TABLE width="100%" align="center"
border=1 cellspacing="0" cellpadding="0" bordercolordark="#000000"
bordercolorlight="#88a6dd">
<tr><td bgcolor="#88a6dd"><font size=2>
主题:</font></td>
<td colspan=3><%=title%></td></tr>
<tr><td bgcolor="#88a6dd"><font size=2>
留言人:</font></td>
<td><%=name%></td><td
bgcolor="#88a6dd"><font size=2>E-mail:</font></td>
<td>
<%
out.println("<a
href=mailto:"+mail+">"+mail+"</a>");
%>
</td></tr>
<tr><td bgcolor="#88a6dd"><font size=2>
留言时间:</font></td><td colspan=3>
<%
out.println("<font size=2>"+date_time+"
"+time_time+"</font>");
%>
</td></tr>
<tr><td align="center">
<%
out.println("("+message_count+")");
%>
</td>
<td colspan=3><%=content%>
</td></tr>
</table>
<%
out.println("<hr>");
message_count--;
}
result.close();
con.close();
}
else
{
out.println("目前还没有任何留言!");
con.close();
}
} catch(Exception e)
{out.println(e);}
%>
<p align="center"><a href="../message/index.html">我要留言</a></p>
</body>
</html>
数据源,我建了一张表单,为message,编写jsp程序调用后出现java.sql.SQLException:
[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name 'message'.
为什么说我的表单非法呢??我的jsp程序如下:(望大虾指点)
<!--view_message.jsp-->
<%@ page import="java.sql.*" %>
<HTML>
<HEAD>
<TITLE> show the message in the table </TITLE>
</HEAD>
<BODY>
<p align="center">所有访客留言</p>
<hr>
<%
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbcdbc:user_db";
Connection con=DriverManager.getConnection(url,"li","781008");
Statement stm=con.createStatement();
ResultSet result=stm.executeQuery("select count(*) from
message");
int message_count=0;
if(result.next())
{
message_count=result.getInt(1);
result.close();
}
if(message_count>0)
{
result=stm.executeQuery("select * from message
order by time desc");
while(result.next())
{
String title=result.getString("title");
String name=result.getString("name");
String mail=result.getString("mail");
Timestamp
time=result.getTimestamp("time");
Date date_time=new
Date(time.getTime());
Time time_time=new
Time(time.getTime());
String
content=result.getString("content");
%>
<TABLE width="100%" align="center"
border=1 cellspacing="0" cellpadding="0" bordercolordark="#000000"
bordercolorlight="#88a6dd">
<tr><td bgcolor="#88a6dd"><font size=2>
主题:</font></td>
<td colspan=3><%=title%></td></tr>
<tr><td bgcolor="#88a6dd"><font size=2>
留言人:</font></td>
<td><%=name%></td><td
bgcolor="#88a6dd"><font size=2>E-mail:</font></td>
<td>
<%
out.println("<a
href=mailto:"+mail+">"+mail+"</a>");
%>
</td></tr>
<tr><td bgcolor="#88a6dd"><font size=2>
留言时间:</font></td><td colspan=3>
<%
out.println("<font size=2>"+date_time+"
"+time_time+"</font>");
%>
</td></tr>
<tr><td align="center">
<%
out.println("("+message_count+")");
%>
</td>
<td colspan=3><%=content%>
</td></tr>
</table>
<%
out.println("<hr>");
message_count--;
}
result.close();
con.close();
}
else
{
out.println("目前还没有任何留言!");
con.close();
}
} catch(Exception e)
{out.println(e);}
%>
<p align="center"><a href="../message/index.html">我要留言</a></p>
</body>
</html>