I earlier tried to connect to mysql from JSP it failed so now I am trying to connect from Java but here is the error it comes up with...
Here is the program ...
[ January 03, 2006: Message edited by: Raghavan Chockalingam ]
Raghavan
SCJP 6
Michael Duffy
Ranch Hand
Joined: Oct 15, 2005
Posts: 163
posted
0
Originally posted by Raghavan Chockalingam: I earlier tried to connect to mysql from JSP it failed so now I am trying to connect from Java but here is the error it comes up with...
Here is the program ...
Why don't you believe the compiler when it tells you what you've done wrong?
Look at the two lines it's complaining about:
createtable.java:8: cannot find symbol symbol : method DriverManager(java.lang.String) location: class CreateTable con = DriverManager("jdbc:mysql://localhost/new_db?user=root&pass word=demoPassword");
You forgot to include the static method call:
^ createtable.java:9: cannot find symbol symbol : method createConnection() location: interface java.sql.Connection Statement stmt = con.createConnection();
There is no create connection method on java.sql.Connection. However, there is a createStatement method:
Read the error messages you get more carefully.
%
Raghavan Chockalingam
Ranch Hand
Joined: Dec 20, 2005
Posts: 77
posted
0
Sorry...I was tired in the morning, I did not have a close look at it...I have solved that problem now. The file compiles properly now but when it runs, it comes up with this error..
As you said, I have two versions now, jdk 1.4.2 and jdk 1.5.0. Right now, the program is compiled in javac of 1.5.0 and I so far think that I am trying to run using java in 1.5.0
How can it use different version of java when i use javac of 1.5.0. Here is the list of environment variables...
[ January 03, 2006: Message edited by: Raghavan Chockalingam ]
Raghavan Chockalingam
Ranch Hand
Joined: Dec 20, 2005
Posts: 77
posted
0
Recently when I tested the verions of java and javac, I found that java.exe's version is 1.4.2 and javac.exe's version is 1.5.0. I do not have a clue why this happened and I am now wondering how to make java to point to 1.5.0....
Raghavan, It is getting Java 1.4 from somewhere on the PATH.
It is likely that another application is pointing to Java 1.4. You can search for java.exe one the hard drive to try and determine which one. Note that you also have Java 1.3 on that path.
You probably have a JRE first on your system path. If you had 'which' installed you could diagnose the problem easily. I'd edit the path and pace a single java entry first and remove the rest.
Raghavan Chockalingam
Ranch Hand
Joined: Dec 20, 2005
Posts: 77
posted
0
guys, I have put new path in place but still java.exe points to 1.4.2
Originally posted by Raghavan Chockalingam: I earlier tried to connect to mysql from JSP it failed so now I am trying to connect from Java but here is the error it comes up with...
Here is the program ...
[ January 03, 2006: Message edited by: Raghavan Chockalingam ]
s wei
Greenhorn
Joined: Jan 04, 2006
Posts: 2
posted
0
Originally posted by s wei:
Maximilian Xavier Stocker
Ranch Hand
Joined: Sep 20, 2005
Posts: 381
posted
0
You already had this same problem in this very thread?!? There is no method called createConnection in java.sql.Connection. Based on the rest of your code you mean to use createStatement.