RE: [suse-programming-e] Statement and ResultSet (first try / new bie)
You need to add your JDBC driver to your classpath when you compile: bash>javac -classpath .:lib/jdbc-driver.jar:lib/other.jar myprogram.java Jonathan Paul Cowherd Linux and Java Administrator Genscape, Inc. Email: jonathan.cowherd@genscape.com Office: (502) 583-3730 Mobile: (502) 314-0444
-----Original Message----- From: Prabu Subroto [mailto:prabu_subroto@yahoo.com] Sent: Wednesday, July 09, 2003 7:06 PM To: Suse Programming List Subject: Re: [suse-programming-e] Statement and ResultSet (first try / new bie)
Hallo Thorsten...
I tried to imported "java.lang.*" but it didn't work. Still the same error message. Here is the error message : " ifirdaus@susefujitsu:~/arsip/proyek> javac LoadDriver.java LoadDriver.java:30: cannot resolve symbol symbol : class Statement location: class LoadDriver Statement stmt = null; ^ LoadDriver.java:31: cannot resolve symbol symbol : class ResultSet location: class LoadDriver ResultSet rs = null; ^ 2 errors ifirdaus@susefujitsu:~/arsip/proyek> "
Here is my code: " import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.lang.*;
// Notice, do not import com.mysql.jdbc.* // or you will have problems!
public class LoadDriver { public static void main(String[] args) {
try { // The newInstance() call is a work around for some // broken Java implementations
Class.forName("com.mysql.jdbc.Driver").newInstance(); System.out.println("The driver was loaded succesfully."); } catch (Exception ex) { // handle the error System.out.println("The driver could not be loaded."); }
try { Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/amt?user=r oot&password=prabumas");
// Do something with the Connection System.out.println("Connection has been built"); // Doing select Query // assume conn is an already created JDBC connection Statement stmt = null; ResultSet rs = null; "
Please teach me... Where the mistake. --- Thorsten Haude <linux@thorstenhau.de> wrote:
Hi,
* Prabu Subroto <prabu_subroto@yahoo.com> [2003-07-08 22:21]:
psubroto@susefujitsu:~/arsip/proyek> javac LoadDriver.java LoadDriver.java:29: cannot resolve symbol symbol : class Statement location: class LoadDriver Statement stmt = null; ^ LoadDriver.java:30: cannot resolve symbol symbol : class ResultSet location: class LoadDriver ResultSet rs = null; ^ 2 errors psubroto@susefujitsu:~/arsip/proyek>
And this is my code: ==== import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; (...)
I'm too lazy to look it up, but I doubt that Statement or ResultSet are in java.lang. You must import them.
Thorsten -- When bad men combine, the good must associate; else they will fall one by one, an unpitied sacrifice in a contemptible struggle. - Edmund Burke
ATTACHMENT part 2 application/pgp-signature
__________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com
-- To unsubscribe, email: suse-programming-e-unsubscribe@suse.com For additional commands, email: suse-programming-e-help@suse.com Archives can be found at: http://lists.suse.com/archive/suse-> programming-e
Hi, * Jonathan Cowherd <jonathan.cowherd@genscape.com> [2003-07-10 01:10]:
You need to add your JDBC driver to your classpath when you compile:
Nope, that wouldn't help. Thorsten -- begin 666 magritte.txt.vbs Ceci n'est pas un attachement. end
participants (2)
-
Jonathan Cowherd
-
Thorsten Haude