File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Beginners problem

 
Rasika Gopalakrishnan
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20368
43
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does user "Rasika" have enough rights to see that table?
 
William P O'Sullivan
Ranch Hand
Posts: 859
Chrome IBM DB2 Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic