Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

error in jdbc

 
preethi Ayyappan
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 531
Java Mac OS X Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
replace


with



you have attached the object type with its name.
 
preethi Ayyappan
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20751
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at your imports - you're importing the wrong Connection class.
 
Jan Cumps
Bartender
Posts: 2608
14
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
... Or you have created a class called Connection in the same package as your class that gives the error.
 
Jan Cumps
Bartender
Posts: 2608
14
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot.That was the mistake.Now its working well.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic