File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Beginners problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Beginners problem" Watch "Beginners problem" New topic
Author

Beginners problem

Rasika Gopalakrishnan
Greenhorn

Joined: Dec 07, 2012
Posts: 7
I am trying a JDBC connection for the first time. I have JDK 1.6, SQL Server 2005 and Microsoft's jdbc driver 3.0. The code goes:

and the test class:


no compiler errors, but on running the test class, i get the following message:


F:\EVM\classes>java com/example/DepartmentLookUp
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'dbo.departmentmaster' doesn't exist
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.Util.getInstance(Util.java:381)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1030)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3515)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3447)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1951)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2101)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2548)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2477)
at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1422)
at com.example.DepartmentLookUp.getDepartment(DepartmentLookUp.java:18)
at com.example.DepartmentLookUp.main(DepartmentLookUp.java:36)

The database name is VisitorLog and table name is DepartmentMaster.

Please help!

Thanks and regards,
Rasika
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19720
    
  20

Does user "Rasika" have enough rights to see that table?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
William P O'Sullivan
Ranch Hand

Joined: Mar 28, 2012
Posts: 859

Your statement has no schema prefix so it is defaulting to "dbo" for some reason.

If you know exactly what schema the table is under then add "schemaname." in front of departmentmaster.

WP
Rasika Gopalakrishnan
Greenhorn

Joined: Dec 07, 2012
Posts: 7
Rob Spoor wrote:Does user "Rasika" have enough rights to see that table?

Yes. The user has the rights to see the table.
Rasika Gopalakrishnan
Greenhorn

Joined: Dec 07, 2012
Posts: 7
William P O'Sullivan wrote:Your statement has no schema prefix so it is defaulting to "dbo" for some reason.

If you know exactly what schema the table is under then add "schemaname." in front of departmentmaster.

WP


The schema name displayed in the table properties is dbo.
 
wood burning stoves
 
subject: Beginners problem