MySQL connectivity issue

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Dec 2006
Posts: 56
Reputation: staneja is an unknown quantity at this point 
Solved Threads: 1
staneja's Avatar
staneja staneja is offline Offline
Junior Poster in Training

MySQL connectivity issue

 
0
  #1
Jul 19th, 2007
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
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 56
Reputation: staneja is an unknown quantity at this point 
Solved Threads: 1
staneja's Avatar
staneja staneja is offline Offline
Junior Poster in Training

Re: MySQL connectivity issue

 
0
  #2
Jul 19th, 2007
Sorry but i am suing follwoing line to craete connection-:

con=DriverManager.getConnection("jdbc:mysql:///dbetech","root","");
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,505
Reputation: Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future 
Solved Threads: 521
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: MySQL connectivity issue

 
0
  #3
Jul 19th, 2007
Use java.sql.Connection for your "con" variable type. Just change the import type and it will be fine.
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 56
Reputation: staneja is an unknown quantity at this point 
Solved Threads: 1
staneja's Avatar
staneja staneja is offline Offline
Junior Poster in Training

Re: MySQL connectivity issue

 
0
  #4
Jul 19th, 2007
Hey......... it worked for me...thanks a lot
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC