• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Connexion Sql server 2008 java

 
nadia ghezaiel
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to connect Sql server 2008 dataBasa and NetBeans 7.3!
I Wrote this code and i don't Know whats the prob??Please help me!!!

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package authentification;

import java.sql.*;

/**
*
* @author Nadia
*/
public class Authentification {

/**
* @param args the command line arguments
*/
public static void main(String[] args) throws ClassNotFoundException {

Connection con = null;
Statement stmt = null;
ResultSet rs = null;

try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");


String url = "jdbc:sqlserver://localhost:1433;databaseName=Authentif;user=Connexion;password=haithem";

con = DriverManager.getConnection(url);

stmt = con.createStatement();
rs = stmt.executeQuery("INSERT INTO Authentif VALUES ('Nadia','ghezaiel@yahoo.com','haithem','haithem')");

}
catch(SQLException se){
System.out.println("SQL exception: " + se.getMessage());
}

}

}


And the exception is:

run:
avr. 13, 2013 3:04:51 PM com.microsoft.sqlserver.jdbc.SQLServerConnection <init>
SEVERE: L'environnement d'exécution Java (JRE, Java Runtime Environment) version 1.7 n'est pas pris en charge par ce pilote. Utilisez la bibliothèque de classes sqljdbc4.jar, qui permet la prise en charge de JDBC 4.0.
Exception in thread "main" java.lang.UnsupportedOperationException: L'environnement d'exécution Java (JRE, Java Runtime Environment) version 1.7 n'est pas pris en charge par ce pilote. Utilisez la bibliothèque de classes sqljdbc4.jar, qui permet la prise en charge de JDBC 4.0.
at com.microsoft.sqlserver.jdbc.SQLServerConnection.<init>(SQLServerConnection.java:223)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:840)
at java.sql.DriverManager.getConnection(DriverManager.java:579)
at java.sql.DriverManager.getConnection(DriverManager.java:243)
at authentification.Authentification.main(Authentification.java:30)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)



 
nadia ghezaiel
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nadia ghezaiel wrote:I want to connect Sql server 2008 dataBasa and NetBeans 7.3!
I Wrote this code and i don't Know whats the prob??Please help me!!!

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package authentification;

import java.sql.*;

/**
*
* @author Nadia
*/
public class Authentification {

/**
* @param args the command line arguments
*/
public static void main(String[] args) throws ClassNotFoundException {

Connection con = null;
Statement stmt = null;
ResultSet rs = null;

try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");


String url = "jdbc:sqlserver://localhost:1433;databaseName=Authentif;user=Connexion;password=haithem";

con = DriverManager.getConnection(url);

stmt = con.createStatement();
rs = stmt.executeQuery("INSERT INTO Authentif VALUES ('Nadia','ghezaiel@yahoo.com','haithem','haithem')");

}
catch(SQLException se){
System.out.println("SQL exception: " + se.getMessage());
}

}

}


And the exception is:

run:
avr. 13, 2013 3:04:51 PM com.microsoft.sqlserver.jdbc.SQLServerConnection <init>
SEVERE: L'environnement d'exécution Java (JRE, Java Runtime Environment) version 1.7 n'est pas pris en charge par ce pilote. Utilisez la bibliothèque de classes sqljdbc4.jar, qui permet la prise en charge de JDBC 4.0.
Exception in thread "main" java.lang.UnsupportedOperationException: L'environnement d'exécution Java (JRE, Java Runtime Environment) version 1.7 n'est pas pris en charge par ce pilote. Utilisez la bibliothèque de classes sqljdbc4.jar, qui permet la prise en charge de JDBC 4.0.
at com.microsoft.sqlserver.jdbc.SQLServerConnection.<init>(SQLServerConnection.java:223)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:840)
at java.sql.DriverManager.getConnection(DriverManager.java:579)
at java.sql.DriverManager.getConnection(DriverManager.java:243)
at authentification.Authentification.main(Authentification.java:30)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)

I use sqljdbc4

 
Rob Spoor
Sheriff
Pie
Posts: 20512
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My French is pretty horrible, but I think it says that your Java 7 virtual machine is not supported by the driver. Try upgrading the sqljdbc JAR file.
 
nadia ghezaiel
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thinks,but how can i upgrading the sqljdbc JAR file??I have JDK 1.7,and i don't know what I should do???
 
nadia ghezaiel
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is great!!!thinks,
 
Rob Spoor
Sheriff
Pie
Posts: 20512
54
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From that last post I assume you have already downloaded the latest version?
 
nadia ghezaiel
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes!!! (y)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic