|
|
Connecting to mySQL database over the LAN
Hello Everyone,
I am using java API's and JDBC to connect to a mySQl server which is
present in the LAN and i use the IP address of the server to specify
the connection URL but I always get the connection error exception
during run time and I have installed the jconnector so i can use the
JDBC connections to the SQL server and added it to my CLASSPATH
environment varriable but still get the same error some one please
help me out.
thanks in advance,
Mithil
|
|
0
|
|
|
|
Reply
|
mithil.mohan (25)
|
3/20/2007 1:03:57 PM |
|
Mithil wrote:
> Hello Everyone,
>
> I am using java API's and JDBC to connect to a mySQl server which is
> present in the LAN and i use the IP address of the server to specify
> the connection URL but I always get the connection error exception
> during run time and I have installed the jconnector so i can use the
> JDBC connections to the SQL server and added it to my CLASSPATH
> environment varriable but still get the same error some one please
> help me out.
Does the remote server allow you to connect from your location?
By default when setting up users, they are only granted to connect from the
localhost.
--
//Aho
|
|
0
|
|
|
|
Reply
|
J
|
3/20/2007 1:18:44 PM
|
|
Thanks for the reply Aho. I am logging in as the root when i am
specifying the username and password so I think that shouldn't make a
difference it actually fails at the point when i am creating the
driver
Class.forName ("com.mysql.jdbc.Driver") that is the exception it
throws. I am sorry I should have mentioned this earlier.
|
|
0
|
|
|
|
Reply
|
Mithil
|
3/20/2007 1:51:26 PM
|
|
On 20 Mar 2007 06:03:57 -0700, Mithil wrote:
> Hello Everyone,
>
> I am using java API's and JDBC to connect to a mySQl server which is
> present in the LAN and i use the IP address of the server to specify
> the connection URL but I always get the connection error exception
> during run time and I have installed the jconnector so i can use the
> JDBC connections to the SQL server and added it to my CLASSPATH
> environment varriable but still get the same error some one please
> help me out.
You keep getting the same error, but you haven't told us what the error
says. "Help! My car won't start! What's wrong?"
--
79. If my doomsday device happens to come with a reverse switch, as soon as it
has been employed it will be melted down and made into limited-edition
commemorative coins.
--Peter Anspach's list of things to do as an Evil Overlord
|
|
0
|
|
|
|
Reply
|
Peter
|
3/20/2007 1:51:26 PM
|
|
it states in my second message, it is an exception actually it doesn't
create the driver for some reason , the exception occurs in this
statement :
Class.forName ("com.mysql.jdbc.Driver")
but i have the jconnector's jar file set to the classpath and also
copied it into the library files of the JVM as said by the document
for the jconnector.
I am sorry for not giving the exact error because I am at work and
don't have my PC which i use in college sorry will type in the exact
error message tomorrow sorry for any problems.
|
|
0
|
|
|
|
Reply
|
Mithil
|
3/20/2007 4:22:40 PM
|
|
I am sorry for all the trouble of not putting up my Question properly
the error i get is :
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
when I run the code:
import java.sql.*;
import java.lang.*;
public class testingJDBC {
/** Creates a new instance of testingJDBC */
public testingJDBC() {
}
public static void main(String argsp[]){
try{
Statement stmt;
Class.forName("com.mysql.jdbc.Driver").newInstance();
String url ="jdbc:mysql://147.25.238.215:3306/test";
Connection con =DriverManager.getConnection(url,"root",
"000000");
stmt = con.createStatement();
stmt.executeUpdate("CREATE DATABASE JunkDB");
}
catch(Exception e){
System.err.println("connection cann't be established
\n"+e);
}
}
}
Please help me out I am stuck at this point.
Thanking you in advance,
Mithil
|
|
0
|
|
|
|
Reply
|
Mithil
|
3/21/2007 1:16:05 PM
|
|
On 21 Mar 2007 06:16:05 -0700, Mithil wrote:
> I am sorry for all the trouble of not putting up my Question properly
> the error i get is :
>
> java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
Perhaps I do not know Java very well. This sounds like an error
indicating that
>
> when I run the code:
>
> import java.sql.*;
> import java.lang.*;
>
> public class testingJDBC {
>
> /** Creates a new instance of testingJDBC */
> public testingJDBC() {
> }
>
>
>
> public static void main(String argsp[]){
> try{
> Statement stmt;
> Class.forName("com.mysql.jdbc.Driver").newInstance();
this line above is the one causing the problem, because it is not where
the interpreter/compiler/runtime enviornment is expecting it to be.
> String url ="jdbc:mysql://147.25.238.215:3306/test";
> Connection con =DriverManager.getConnection(url,"root",
> "000000");
> stmt = con.createStatement();
> stmt.executeUpdate("CREATE DATABASE JunkDB");
> }
> catch(Exception e){
> System.err.println("connection cann't be established
> \n"+e);
> }
> }
> }
>
>
> Please help me out I am stuck at this point.
>
> Thanking you in advance,
> Mithil
>
--
100. Finally, to keep my subjects permanently locked in a mindless trance, I
will provide each of them with free unlimited Internet access.
--Peter Anspach's list of things to do as an Evil Overlord
|
|
0
|
|
|
|
Reply
|
Peter
|
3/21/2007 5:52:57 PM
|
|
|
6 Replies
321 Views
(page loaded in 0.129 seconds)
|
|
|
|
|
|
|
|
|