5 Replies - 1144 Views - Last Post: 06 December 2010 - 02:07 PM Rate Topic: -----

#1 seyidesh  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 51
  • Joined: 24-November 10

MYSQL Connection Problem

Posted 06 December 2010 - 08:39 AM

Guys kindly help me check this codes of my, for Connecting Netben to MYSQL, i have install the driver to this directory
 C:\Program Files\Java\jdk1.6.0_22\bin 


THIS IS ACTION PERFORMED FOR "SAVE" BUTTON.
 private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
       try{
Class.forName("com.mysql.jdbc.Driver");
//DriverManager.registerDriver(new org.apache.derby.jdbc.ClientDriver());
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/NIPC", "root", "");
stat = con.prepareStatement("INSERT INTO Payroll(id, FirstName, MiddleName, LastName, DOB, Gender, Address, DateOfLAP, DateOfPAP, Basic, Medical Housing, TaxPaid, NetPay, GrossPay) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
String idval = jTextField1.getText();
String fnamebox = jTextField2.getText();
String mnamebox = jTextField3.getText();
String lnamebox = jTextField4.getText();
String dob = jTextField5.getText();
String sex = (String)jComboBox1.getSelectedItem();
String address = jTextArea1.getText();
String  lastapp = jTextField6.getText();
String  currentapp = jTextField7.getText();
String  basicallowance = jTextField8.getText();
String houseallowance = jTextField9.getText();
String medicalallowance = jTextField10.getText();
String taxdeduce = jTextField11.getText();
String netp = jTextField12.getText();
String grossp = jTextField13.getText();

stat.setString(1, idval);
stat.setString(2, fnamebox);
stat.setString(3, mnamebox);
stat.setString(4, lnamebox);
stat.setString(5, dob);
stat.setString(6, sex);
stat.setString(7, address);
stat.setString(8, lastapp);
stat.setString(9, currentapp);
stat.setString(10, basicallowance);
stat.setString(11, houseallowance);
stat.setString(12, medicalallowance );
stat.setString(13, taxdeduce);
stat.setString(14, netp);
stat.setString(15, grossp);

stat.executeQuery();
con.close();
jLabel18.setText("Record saved");
}

catch(Exception se){System.out.println("Error"+se);
jLabel18.setText("Record saved with exceptions");}
//}



WHEN I RUN THIS PROGRAMME THE ERROR I SAW WAS:

Errorjava.lang.ClassNotFoundException: com.mysql.jdbc.Driver



Kindly help me check where i got it all wrong.

Is This A Good Question/Topic? 0
  • +

Replies To: MYSQL Connection Problem

#2 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2639
  • View blog
  • Posts: 11,153
  • Joined: 20-September 08

Re: MYSQL Connection Problem

Posted 06 December 2010 - 08:51 AM

Quote

i have install the driver to this directory


Don't put it there. Copy the driver jar to a directory given by the following

System.out.println(System.getProperty("java.ext.dirs"));

Was This Post Helpful? 0
  • +
  • -

#3 seyidesh  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 51
  • Joined: 24-November 10

Re: MYSQL Connection Problem

Posted 06 December 2010 - 10:12 AM

Guys i have issues connecting my programme from netben to MYSQL, i jave installed MYSQL driver to this directory
C:\Program Files\Java\jdk1.6.0_22\bin


THE ACTION PERFORMED CODES FOR THE BUTTON "SAVE" IS THIS:
  private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
       try{
Class.forName("com.mysql.jdbc.Driver");
//DriverManager.registerDriver(new org.apache.derby.jdbc.ClientDriver());
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/NIPC", "root", "");
stat = con.prepareStatement("INSERT INTO Payroll(id, FirstName, MiddleName, LastName, DOB, Gender, Address, DateOfLAP, DateOfPAP, Basic, Medical Housing, TaxPaid, NetPay, GrossPay) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
String idval = jTextField1.getText();
String fnamebox = jTextField2.getText();
String mnamebox = jTextField3.getText();
String lnamebox = jTextField4.getText();
String dob = jTextField5.getText();
String sex = (String)jComboBox1.getSelectedItem();
String address = jTextArea1.getText();
String  lastapp = jTextField6.getText();
String  currentapp = jTextField7.getText();
String  basicallowance = jTextField8.getText();
String houseallowance = jTextField9.getText();
String medicalallowance = jTextField10.getText();
String taxdeduce = jTextField11.getText();
String netp = jTextField12.getText();
String grossp = jTextField13.getText();

stat.setString(1, idval);
stat.setString(2, fnamebox);
stat.setString(3, mnamebox);
stat.setString(4, lnamebox);
stat.setString(5, dob);
stat.setString(6, sex);
stat.setString(7, address);
stat.setString(8, lastapp);
stat.setString(9, currentapp);
stat.setString(10, basicallowance);
stat.setString(11, houseallowance);
stat.setString(12, medicalallowance );
stat.setString(13, taxdeduce);
stat.setString(14, netp);
stat.setString(15, grossp);

stat.executeQuery();
con.close();
jLabel18.setText("Record saved");
}

catch(Exception se){System.out.println("Error"+se);
jLabel18.setText("Record saved with exceptions");}
//}



THE ERROR MASSAGE AFTER RUN IS
Errorjava.lang.ClassNotFoundException: com.mysql.jdbc.Driver


guys kindly help me out.

This post has been edited by seyidesh: 06 December 2010 - 10:16 AM

Was This Post Helpful? 0
  • +
  • -

#4 vasdueva  Icon User is offline

  • D.I.C Head

Reputation: 15
  • View blog
  • Posts: 141
  • Joined: 03-April 07

Re: MYSQL Connection Problem

Posted 06 December 2010 - 11:47 AM

Have you added the jar to your class path?
Was This Post Helpful? 0
  • +
  • -

#5 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6033
  • View blog
  • Posts: 23,415
  • Joined: 23-August 08

Re: MYSQL Connection Problem

Posted 06 December 2010 - 12:29 PM

Merged duplicate topics. Please do NOT create a new topic when you already have one on the same subject.
Was This Post Helpful? 0
  • +
  • -

#6 m-e-g-a-z  Icon User is offline

  • Winning
  • member icon


Reputation: 496
  • View blog
  • Posts: 1,453
  • Joined: 19-October 09

Re: MYSQL Connection Problem

Posted 06 December 2010 - 02:07 PM

Just add the MySQL JAR using your Netbeans IDE - Read This.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1