• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jdbc compilation error too weird

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 SqlConnection.java
SqlConnection.java:9: 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
SqlConnection.java:10: 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>

 
Marshal
Posts: 79180
377
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What does it say in the getConnection method documentation?
Have you got another Connection class of your own?
 
gopal krishnan
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i'm not defining it.. using the existing..
 
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic