Connection to MySQL AB
Hello,
I can't seem to get this right.
I'm pretty sure that the problem is in this line, if not the sourc follows.
Thanks,
Jeff.
String url = "jdbc:mysql://localhost/user=root&password=password";
/*
* Main.java
*
* Created on December 5, 2005, 12:32 PM
*/
package CreateCoffees;
/**
*
* @author jspence
*/
import java.sql.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class CreateCoffees {
public static void main(String args[]) {
String url = "jdbc:mysql://localhost/user=root&password=password";
Connection con;
String createString;
createString = "create table COFFEES " +
"(COF_NAME VARCHAR(32), " +
"SUP_ID INTEGER, " +
"PRICE FLOAT, " +
"SALES INTEGER, " +
"TOTAL INTEGER)";
Statement stmt;
try {
Class.forName ("com.mysql.jdbc.Driver"); //("myDriver.ClassName");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url);
stmt = con.createStatement();
stmt.executeUpdate(createString);
stmt.close();
con.close();
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
}
}

