Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem while connecting to mysql using mm jdbc driver

Status
Not open for further replies.

mithra

Programmer
May 26, 2000
21
IN
Hi , Here is my problem:<br>&nbsp;&nbsp;I am trying to connect to mysql using mm.mysql.jdbc-1.2c Driver , But I am not able to connect :<br>&nbsp;&nbsp;The Source code I used :<br>**********************************<br>&nbsp;&nbsp;import java.sql.*;<br>&nbsp;&nbsp;&nbsp;public class Test {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public static void main(String args[]) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(&quot;This is the First Line&quot;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Class.forName(&quot;org.gjt.mm.mysql.Driver&quot;).newInstance();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(&quot;Line After forName&quot;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}catch(Exception E) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.error.println(&quot;Unable to Load Driver&quot;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;E.printStackTrace();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(&quot;Line Before Connecting&quot;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Connection conn = DriverManager.getConnection(&quot;jdbc:mysql://localhost&quot;, &quot;root&quot;, &quot;password&quot;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(&quot;Line after Connecting&quot;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(&quot;conn.getTransactionIsolation());<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}catch(Exception ex) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ex.printStackTrace();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;}<br><br>*****************************************<br>&nbsp;The OutPut I am getting Is :<br>&nbsp;&nbsp;This is the First Line<br>&nbsp;&nbsp;Line After forName<br>&nbsp;&nbsp;Line Before Connecting<br>&nbsp;&nbsp;java.sql.SQLException: No suitable Driver.<br>*************************************************<br>If I change my connecting url as : &quot;jdbc:mysql://localhost/dbname?user=root$pasword=passwd&quot;<br><br>I will get the Error message :<br><br>java.sql.SQLExeption : Invalid authorization specification :<br>&nbsp;&nbsp;&nbsp;Access denied for user : 'root@localhost' (Using Password:YES)<br><br>&nbsp;&nbsp;Please Give me the Solution.<br><br>Thank U In Advance;<br><br>Email: <A HREF="mailto:venkatesh_mithra@hotmail.com">venkatesh_mithra@hotmail.com</A><br><br>&nbsp;&nbsp;&nbsp;&nbsp;<br><br><br><br><br><br><br><br><br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 
i have a similar problem but i'm getting an error which asks if there is a mySQL server running on that machine, i'm not sure if the server is set up correctly or if it has something to do with my coding<br><br>if you have got it to work please let me know<br><br>thankx<br><br>Brett
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top