那位大虾帮我解决以下一个关于数据库联接的问题
异常:
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]对象名 'wareTable ' 无效。
at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSExecuteRequest.processReplyToken(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source)
at com.microsoft.jdbc.sqlserver.SQLServerImplStatement.getNextResultType(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.commonTransitionToState(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.postImplExecute(Unknown Source)
at com.microsoft.jdbc.base.BasePreparedStatement.postImplExecute(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.commonExecute(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.executeUpdateInternal(Unknown Source)
at com.microsoft.jdbc.base.BasePreparedStatement.executeUpdate(Unknown Source)
at com.xue.market.DAO.Operation.Update(Operation.java:15)
at com.xue.market.Servlet.market.doPost(market.java:46)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
数据库联接类:
public class GetCon {
public GetCon() {
}
private Connection con = null;
public Connection Getcon() {
try {
Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver ");
con = DriverManager.getConnection(
"jdbc:microsoft:sqlserver://localhost:1433;databasename = market ",
"sa ", "sa ");
} catch (SQLException ex) {
ex.printStackTrace();
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
}
return con;
}
}
执行更新的类:
public boolean Update(String sql) {
try {
PreparedStatement ps = c.Getcon().prepareStatement(sql);
int i = ps.executeUpdate();
if (i > 0) {
flag = true;
} else {
flag = false;
}
} catch (SQLException ex) {
ex.printStackTrace();
}
return flag;
}
[解决办法]
表明无效啊,看看命名是否规范
[解决办法]
你的wareTable创建后还没有给用户授权,在表\属性\权限 中看看是不是没有钩上
[解决办法]
先试一下直接在数据库里能操作这个表么
[解决办法]
这个数据库名无效吧 wareTable
要不全大写要不全小写吧
[解决办法]
1.检查代码.
2.最好能升级SQL Server2000到sp4.
3.JDBC的驱动下载最新.
4.用户名和密码错误,或者给定的用户没有权限.
5.端口错误.