Java and mysql together
From: Advocated (......_at_......com)
Date: 02/28/04
- Previous message: Jonathan Fuerth: "Re: Zooming/Scaling a JPanel"
- Next in thread: Lloyd: "Re: Java and mysql together"
- Reply: Lloyd: "Re: Java and mysql together"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 28 Feb 2004 01:29:11 -0000
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
- Previous message: Jonathan Fuerth: "Re: Zooming/Scaling a JPanel"
- Next in thread: Lloyd: "Re: Java and mysql together"
- Reply: Lloyd: "Re: Java and mysql together"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|