File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Connexion Sql server 2008 java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Connexion Sql server 2008 java" Watch "Connexion Sql server 2008 java" New topic
Author

Connexion Sql server 2008 java

nadia ghezaiel
Ranch Hand

Joined: Apr 13, 2013
Posts: 40
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

Joined: Apr 13, 2013
Posts: 40
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

Joined: Oct 27, 2005
Posts: 19695
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
nadia ghezaiel
Ranch Hand

Joined: Apr 13, 2013
Posts: 40
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

Joined: Apr 13, 2013
Posts: 40
It is great!!!thinks,
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19695
    
  20

From that last post I assume you have already downloaded the latest version?
nadia ghezaiel
Ranch Hand

Joined: Apr 13, 2013
Posts: 40
yes!!! (y)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Connexion Sql server 2008 java