aspose file tools
The moose likes JDBC and Relational Databases and the fly likes jdbc compilation error too weird Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "jdbc compilation error too weird" Watch "jdbc compilation error too weird" New topic

jdbc compilation error too weird

gopal krishnan

Joined: Dec 17, 2007
Posts: 18
i am trying to execute the below simple java program
but i am getting the below error..

getting the below compilation error, seems to be too weired.

C:\Documents and Settings\gopc\workspace\JDBC_Connection\src>javac error: incompatible types
con = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Acess Driver (*.accdb)}; DBQ=C:\\Users\\gopc\\odbc_sql.accdb","","");
required: Connection
found: java.sql.Connection error: cannot find symbol
Statement statement = con.createStatement();
symbol: method createStatement()
location: variable con of type Connection
2 errors

C:\Documents and Settings\gopc\workspace\JDBC_Connection\src>

Campbell Ritchie

Joined: Oct 13, 2005
Posts: 40447
What does it say in the getConnection method documentation?
Have you got another Connection class of your own?
gopal krishnan

Joined: Dec 17, 2007
Posts: 18
i'm not defining it.. using the existing..
Wendy Gibbons

Joined: Oct 21, 2008
Posts: 1107

on the line you declare the con variable explicitly give the whole lot: java.sql.connection (getting the case correct).
and the same for driver mananger java.sql.DriverManager.
Just to see if somehow you are not using the classes you expect to be.
Matthew Brown

Joined: Apr 06, 2010
Posts: 4499

It does look like you have another Connection class in the same package. Possibly a compiled version that's hanging around even if you've deleted the source code. If you examined what Connection.class referred to it would confirm it.
It is sorta covered in the JavaRanch Style Guide.
subject: jdbc compilation error too weird