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


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "error in jdbc" Watch "error in jdbc" New topic
Author

error in jdbc

preethi Ayyappan
Ranch Hand

Joined: Oct 04, 2007
Posts: 518
hi,when i am compiling my java program it is showing the following error


c:\j2sdk1.4.2_16\bin>javac ListTables.java
found:java.sql.Connection
required:ConnectionCon=DriverManager.grtConnection("jdbc:mysql://192.168.1.5:3306/test","dialer","1234");


Anyone please help me to find why this happens.
Masoud Kalali
Author
Ranch Hand

Joined: Jul 08, 2004
Posts: 531

replace


with



you have attached the object type with its name.


Masoud Kalali
Software Engineer - My Weblog - GlassFish Security
preethi Ayyappan
Ranch Hand

Joined: Oct 04, 2007
Posts: 518
Hi,
Thanks for your reply.

Connection Con=DriverManager.getConnection("jdbc:mysql://192.168.1.5:3306/test","dialer","1234");
.
I tried this.I think i had posted wrongly in the last post as "ConnectionCon".In my program it was "Connection Con" only.Now also i am getting the same error.I had installed new version of mysql jar file too .Now too i am getting the same error. Any idea???
preethi Ayyappan
Ranch Hand

Joined: Oct 04, 2007
Posts: 518
I am getting these errors even after i had installed new version of mysql.
I am unable to find where i am wrong.

Connection.java:19: incompatible types
found : java.sql.Connection
required: Connection
conn = DriverManager.getConnection ("jdbc:mysql://192.168.1.5:3306/test","dialer","1234");
^
Connection.java:20: cannot find symbol
symbol : method createStatement()
location: class Connection
st = conn.createStatement();
^

[ January 10, 2008: Message edited by: preethi Ayyappan ]
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19783
    
  20

Take a look at your imports - you're importing the wrong Connection class.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2516
    
  10

... Or you have created a class called Connection in the same package as your class that gives the error.


OCUP UML fundamental and ITIL foundation
youtube channel
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2516
    
  10

Ah. Now I see it:

Your class is called Connection.
So if you define a variable Connection conn;
this variable will not be of type java.sql.Connection, but of your.package.Connection.

Either rename your class, oir define the variable declaration as:
java.sql.Connection conn;
conn = DriverManager.getConnection ("jdbc:mysql://192.168.1.5:3306/test","dialer","1234");
preethi Ayyappan
Ranch Hand

Joined: Oct 04, 2007
Posts: 518
Thanks a lot.That was the mistake.Now its working well.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: error in jdbc