Hi there, this is my last hope of using sql, ive collected loads of
tutorials etc of just connecting to a mysql database, but so far all have
been the same, therefore none have worked.
This is my code so far:
############################################################################
package Security;
import java.sql.*;
public class sql extends javax.swing.JFrame {
public sql() {
initComponents();
String url = "jdbc:mysql://localhost:3306/javalogin";
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con=DriverManager.getConnection(url,"myusername",
"mypass");
Statement stmt = con.createStatement();
stmt.executeUpdate("INSERT INTO users " + "VALUES ('180',
270)");
}
catch(Exception e){
System.out.println(e);
}
}
private void initComponents() {
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
exitForm(evt);
}
});
pack();
}
private void exitForm(java.awt.event.WindowEvent evt) {
System.exit(0);
}
public static void main(String args[]) {
new sql().show();
}
}
##############################################################
the idea is i connect to the javalogin database, and then try and add some
values into a table called users.
My mysql tables/databases have already been created and are fine.
Problem comes when i run it, it compiles ok, but on run i get this error:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
Im not sure what im doing wrong, but the way my program is with its folders
etc is:
C:\Security\ then all my files are in here:
This includes:
sql.java, sql.class, mysql.jar - i also tried unpacking this and just
putting the com and org folders in Security but that had the same problem.
I just cant work this out, Any ideas please
Lloyd - 28 Feb 2004 04:25 GMT
> Hi there, this is my last hope of using sql, ive collected loads of
> tutorials etc of just connecting to a mysql database, but so far all have
> been the same, therefore none have worked.
>
> This is my code so far:
############################################################################
> package Security;
> import java.sql.*;
[quoted text clipped - 50 lines]
> sql.java, sql.class, mysql.jar - i also tried unpacking this and just
> putting the com and org folders in Security but that had the same problem.
What is the command line you are using to run this app? I suspect it's a
classpath problem.
Advocated - 28 Feb 2004 08:07 GMT
<Snip<
> What is the command line you are using to run this app? I suspect it's a
> classpath problem.
Well, ive been running it via JCreator, not directly thorough the CLI
Advocated - 29 Feb 2004 16:19 GMT
I still have'nt been able to fix this, any ideas how to do it via JCreator?
Cheers