We help IT Professionals succeed at work.

Error: Invalid object name

rzepeda57
rzepeda57 asked
on
648 Views
Last Modified: 2012-05-11
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.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.BaseStatement.commonExecute(Unknown Source)
        at com.microsoft.jdbc.base.BaseStatement.executeQueryInternal(Unknown Source)
        at com.microsoft.jdbc.base.BaseStatement.executeQuery(Unknown Source)
        at hn.claro.prepago.Test.<init>(Test.java:75)
        at hn.claro.prepago.Test.main(Test.java:124)

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();
            }

Open in new window

Comment
Watch Question

Java Developer
CERTIFIED EXPERT
Top Expert 2010
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Thanks for the help.
Awarded 2011
Awarded 2011

Commented:
Still it prints

Successfully connected

etc.

are you sure you have the table tbl_user ?

Did you run thsi query directly from SQL prompt?
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.