rzepeda57
asked on
Error: Invalid object name
Hi,
can somebody help with this exception that I'm recived after trying to execute the next query
sql = "select * from tbl_user";
ResultSet rs = stmt.executeQuery(sql);
I have try adding the owner of the table and i still keep getting the same error. I can connect to the database. This is the output that I'm getting.
Successfully connected
Driver Information
Driver Name: SQLServer
Driver Version: 2.2.0022
Database Information
Database Name: Microsoft SQL Server
Database Version: Microsoft SQL Server 2000 - 8.00.760 (Intel X86)
Dec 17 2002 14:22:05
Copyright (c) 1988-2003 Microsoft Corporation
Standard Edition on Windows NT 5.2 (Build 3790: )
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Invalid object name 'tbl_user'.
at com.microsoft.jdbc.base.Ba seExceptio ns.createE xception(U nknown Source)
at com.microsoft.jdbc.base.Ba seExceptio ns.getExce ption(Unkn own Source)
at com.microsoft.jdbc.sqlserv er.tds.TDS Request.pr ocessError Token(Unkn own Source)
at com.microsoft.jdbc.sqlserv er.tds.TDS Request.pr ocessReply Token(Unkn own Source)
at com.microsoft.jdbc.sqlserv er.tds.TDS ExecuteReq uest.proce ssReplyTok en(Unknown Source)
at com.microsoft.jdbc.sqlserv er.tds.TDS Request.pr ocessReply (Unknown Source)
at com.microsoft.jdbc.sqlserv er.SQLServ erImplStat ement.getN extResultT ype(Unknow n Source)
at com.microsoft.jdbc.base.Ba seStatemen t.commonTr ansitionTo State(Unkn own Source)
at com.microsoft.jdbc.base.Ba seStatemen t.postImpl Execute(Un known Source)
at com.microsoft.jdbc.base.Ba seStatemen t.commonEx ecute(Unkn own Source)
at com.microsoft.jdbc.base.Ba seStatemen t.executeQ ueryIntern al(Unknown Source)
at com.microsoft.jdbc.base.Ba seStatemen t.executeQ uery(Unkno wn Source)
at hn.claro.prepago.Test.<ini t>(Test.ja va:75)
at hn.claro.prepago.Test.main (Test.java :124)
can somebody help with this exception that I'm recived after trying to execute the next query
sql = "select * from tbl_user";
ResultSet rs = stmt.executeQuery(sql);
I have try adding the owner of the table and i still keep getting the same error. I can connect to the database. This is the output that I'm getting.
Successfully connected
Driver Information
Driver Name: SQLServer
Driver Version: 2.2.0022
Database Information
Database Name: Microsoft SQL Server
Database Version: Microsoft SQL Server 2000 - 8.00.760 (Intel X86)
Dec 17 2002 14:22:05
Copyright (c) 1988-2003 Microsoft Corporation
Standard Edition on Windows NT 5.2 (Build 3790: )
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Invalid object name 'tbl_user'.
at com.microsoft.jdbc.base.Ba
at com.microsoft.jdbc.base.Ba
at com.microsoft.jdbc.sqlserv
at com.microsoft.jdbc.sqlserv
at com.microsoft.jdbc.sqlserv
at com.microsoft.jdbc.sqlserv
at com.microsoft.jdbc.sqlserv
at com.microsoft.jdbc.base.Ba
at com.microsoft.jdbc.base.Ba
at com.microsoft.jdbc.base.Ba
at com.microsoft.jdbc.base.Ba
at com.microsoft.jdbc.base.Ba
at hn.claro.prepago.Test.<ini
at hn.claro.prepago.Test.main
DriverManager.registerDriver(new com.microsoft.jdbc.sqlserver.SQLServerDriver());
Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://host:1433", "sa", "");
if (connection != null) {
System.out.println();
System.out.println("Successfully connected");
System.out.println();
// Meta data
DatabaseMetaData meta = connection.getMetaData();
System.out.println("\nDriver Information");
System.out.println("Driver Name: " + meta.getDriverName());
System.out.println("Driver Version: " + meta.getDriverVersion());
System.out.println("\nDatabase Information ");
System.out.println("Database Name: " + meta.getDatabaseProductName());
System.out.println("Database Version: " + meta.getDatabaseProductVersion());
Statement stmt = connection.createStatement();
try{
sql = "select * from tbl_user";
ResultSet rs = stmt.executeQuery(sql);
} catch (Exception ex) {
ex.printStackTrace();
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Still it prints
Successfully connected
etc.
are you sure you have the table tbl_user ?
Did you run thsi query directly from SQL prompt?
Successfully connected
etc.
are you sure you have the table tbl_user ?
Did you run thsi query directly from SQL prompt?
ASKER