I am a beginner in Java having only limited knowledge in SQL commands say 5 or 6 commands... I tried connecting my Java project with an access database "aman.accdb" using ODBC in my laptop.. The database has a table named "tab".. I am using a windows 7 64 bit pc with Java JDK for 64 bit installed in it. And also I use ms office 2013 which is also a 64 bit product.
When I executed the code an error " java.sql.SQLException No suitable drivers found for jdbc:odbc:man" I am posting the sample code which caused an error below. I have removed the unwanted lines such as layout setting and all as it runs for pages.
Please provide a solution to this!
package sample;
import java.sql.*;
import javax.swing.JOptionPane;
public class als extends javax.swing.JFrame {
public als() throws SQLException {
initComponents();
try
{
con=DriverManager.getConnection("jdbc:odbc:man") ;
}catch(Exception e)
{
JOptionPane.showMessageDialog(null, e);
}
}
private void initComponents() {
jButton1 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jButton1.setText("Check");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
try
{
st=con.createStatement();
String s=("insert into tab ('senthil',12)");
st.execute(s);
JOptionPane.showMessageDialog(rootPane,"Saved");
this.setVisible(false);
}catch(Exception e)
{
JOptionPane.showMessageDialog(rootPane,e);
}
}
static Connection con;
static Statement st;
static ResultSet rs;
private javax.swing.JButton jButton1;
}
I came to know that this problem occurs in 64 bit OS oly.. Will this not happen if I install a 32 bit OS.
Note : The error I got is an exception which I displayed through a message box in catch()
part in constructor als()
.