This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
i fisrt in the linux box type these command #CLASSPATH=.:/usr/java/mysqldriver/mysql-connector-java-3.0.11-stable/mysql-connector-java-3.0.11-stable-bin.jar #export CLASSPATH i can run my helloworl.java program but when i try work with java and mysql in linux i get these error: "java.sql.SQLException: Driver not found for URL: jdbc:mysql://localhost:3306/listas/" (the databases listas exist!!) any advice? (javac OK but java jdbc1 not)
public class jdbc1 { public static void main (String arg[]) { try { // new Driver(); Class.forName("com.mysql.jdbc.Driver"); Properties props = new Properties(); props.setProperty("user","root"); props.setProperty("password","123456"); // props.setProperty("password","123456"); //Table[] cells = new Table[colNames.length]; Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/listas/", props); Statement stmt = con.createStatement(); String query = "SELECT * FROM tdatgen where cdatgenclave like 'ACOACO%'"; ResultSet answer = stmt.executeQuery(query); ResultSetMetaData meta = answer.getMetaData(); int colCount= meta.getColumnCount(); while (answer.next()) { for (int col=1;col<colCount;col++) { System.out.print(answer.getString(col) +"\n"); try { Thread.sleep(4000); } catch (Exception ee){} //cells[col].add(cell); } } } catch (Exception Ex) { System.out.println(Ex.toString()); } } }
Thanks
Jason Steele
Ranch Hand
Joined: Apr 25, 2003
Posts: 100
posted
0
"java.sql.SQLException: Driver not found for URL: jdbc:mysql://localhost:3306/listas/" (the databases listas exist!!)
This error means that your url is not formed in a manner that coincides with a registered driver. the url for mysql should look like this:
I think your error is with your trailing "/" after listas. Try removing it.
An egg is a chicken's house!
wayne hitchcock
Greenhorn
Joined: Dec 22, 2003
Posts: 8
posted
0
I believe Jason's answer to be correct. I always include the user name & password within the url private String url = "jdbc:mysql://localhost:3306/machine_info?user=mm_webapp&password=zero31russell";
Miguel Enriquez
Ranch Hand
Joined: Mar 13, 2004
Posts: 71
posted
0
i continue with my error: "java.sql.SQLException: Driver not found for URL: jdbc:mysql://localhost:3306/listas/" i modified my program: import java.sql.*; import java.util.*; import java.io.*; import com.mysql.jdbc.Driver; import java.util.Timer; public class jdbc2 { public static void main (String arg[]) { try { // new Driver(); Class.forName("com.mysql.jdbc.Driver").newInstance(); String User="root"; String Password="linuxx"; String Url="localhost/listas"; String Res="jdbc:mysql://"+Url+"?user="+User+"&password="+Password; try { Connection dbcon; dbcon=DriverManager.getConnection(Res); Statement stmt = dbcon.createStatement(); String query = "SELECT * FROM tdatgen where cdatgenclave like 'ACOACO%'"; ResultSet resp = stmt.executeQuery(query); ResultSetMetaData meta = resp.getMetaData(); int colCount= meta.getColumnCount(); while (resp.next()) { for (int col=1;col<colCount;col++) { System.out.print(resp.getString(col) +"\n"); try { Thread.sleep(4000); } catch (Exception ee){} //cells[col].add(cell); } } } catch (SQLException ex) { while (ex != null) { System.out.println("SQL:"+ex.getMessage()); ex=ex.getNextException(); } } } catch (Exception Ex) { System.out.println(Ex.toString()); } } } much thanks for yours times.....
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.