944,141 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Marked Solved
  • Views: 913
  • Java RSS
Jul 19th, 2007
0

MySQL connectivity issue

Expand Post »
I am trying to create a calss with a constructior that creates connection with MYSql database , i am using database name as dbetch . I have set the path varable but still it id throwing error



package login;
import java.sql.*;
import java.sql.DriverManager;
import com.mysql.jdbc.Connection;
public class conn {
Connection con=null;
ResultSet rs=null;
Statement st=null;

public conn() {
Class.forName("com.mysql.jdbc.Driver");

con=DriverManager.getConnection("jdbc:mysql://localhost/dbetech","root","");
}
}


Errorr thrown
D:\etech\WEB-INF\src>javac *.java
conn.java:18: incompatible types
found : java.sql.Connection
required: com.mysql.jdbc.Connection
con=DriverManager.getConnection("jdbc:mysql:///dbetech","root","");

1 error
Similar Threads
Reputation Points: 10
Solved Threads: 2
Junior Poster in Training
staneja is offline Offline
63 posts
since Dec 2006
Jul 19th, 2007
0

Re: MySQL connectivity issue

Sorry but i am suing follwoing line to craete connection-:

con=DriverManager.getConnection("jdbc:mysql:///dbetech","root","");
Reputation Points: 10
Solved Threads: 2
Junior Poster in Training
staneja is offline Offline
63 posts
since Dec 2006
Jul 19th, 2007
0

Re: MySQL connectivity issue

Use java.sql.Connection for your "con" variable type. Just change the import type and it will be fine.
Moderator
Featured Poster
Reputation Points: 3239
Solved Threads: 839
Posting Genius
Ezzaral is offline Offline
6,761 posts
since May 2007
Jul 19th, 2007
0

Re: MySQL connectivity issue

Hey......... it worked for me...thanks a lot
Reputation Points: 10
Solved Threads: 2
Junior Poster in Training
staneja is offline Offline
63 posts
since Dec 2006

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: How to generate a list of permutations for a given binary number
Next Thread in Java Forum Timeline: Trying to configure the logger in java





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC