Link to home
Start Free TrialLog in
Avatar of rzepeda57
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.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

ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rzepeda57
rzepeda57

ASKER

Thanks for the help.
Still it prints

Successfully connected

etc.

are you sure you have the table tbl_user ?

Did you run thsi query directly from SQL prompt?