I am using netbeans to build this program,but it give this error java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(DriverManager.java:545)
at java.sql.DriverManager.getConnection(DriverManager.java:193)
at test.Main.<init>(Main.java:33)
at test.Main.main(Main.java:72)
how can fix it
/*
* Main.java
*
* Created on 14 نوار, 2006, 07:39 م
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package test;
/**
*
* @author yasmeen
*/
import java.awt.*;
import java.sql.*;
import java.util.*;
import javax.swing.*;
public class Main extends JFrame {
static final String JDBC_DRIVER="sun.jdbc.odbc.JdbcOdbcDriver";
static final String DATABASE_URL="jdcb:odbc:name";
private Connection connect;
private Statement state;
/** Creates a new instance of Main */
public Main() {
try{
System.setProperty("odbc.system.home","C:/program files/java/jdk1.5.0_01") ;
Class.forName(JDBC_DRIVER);
connect=DriverManager.getConnection("jdcb:odbc:name");
state=connect.createStatement();
ResultSet result=state.executeQuery("select * from my");
StringBuffer results= new StringBuffer();
ResultSetMetaData meta= result.getMetaData();
int c=meta.getColumnCount();
for(int i=1;i<=c;i++)
results.append(meta.getColumnName(i)+"\t");
results.append("\n");
while (result.next()){
for(int i=1;i<=c;i++)
results.append(result.getObject(i)+"\t");
results.append("\n");
}
JTextArea text = new JTextArea(results.toString());
Container d=getContentPane();
d.add(new JScrollPane(text));
setSize(300,100);
setVisible(true);
// TODO code application logic here
}
catch(ClassNotFoundException ex){
System.out.println("cannot load");
System.exit(1);}
catch(SQLException en){
en.printStackTrace();
System.exit(1);}
catch(Exception e){}
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Main v= new Main();
v.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);}
}