Exception in thread "main" java.lang.NullPointerException
Bonjour a tous ,
je travaille sur un petite application sur netveans 7.1.2 et que je vais la connecter avec sql server 2008 .
voila mon jdbc que j'ai realisé
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| import java.sql.*;
import javax.swing.JOptionPane;
public class jdbc {
public static void main(String args[]) {
Connection conn=null;
try{
String jdbcdriver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
String URL="jdbc:odbc:CN";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection(URL);
JOptionPane.showMessageDialog(null, "Connection Succed ! Bravo");
Statement requete = conn.createStatement();
requete.executeUpdate("select * from base");
}catch(Exception e){
e.getCause();
System.out.println("Connection Failed !"+e.toString());
}
finally {
try {conn.close();}
catch(SQLException e) {}
}
}
} |
je sais pas ou est le problème mais il me donne comme même une erreur de sorte :
Citation:
run:
Exception in thread "main" java.lang.NullPointerException
Connection Failed !java.sql.SQLException: [Microsoft][Gestionnaire de pilotes ODBC] La source de donn?es (DSN) sp?cifi?e pr?sente une incompatibilit? d'architecture entre le pilote et l'application
at jdbc.main(jdbc.java:29)
et merci de votre aide