Hi!
I'm learning to build a database application using Netbeans IDE 7.2.1 and Microsoft SQL Server 2008 R2.
I found a basic program(the first step) to create a connection between the two. But I'm getting the following error.
I'm doing this for the first time so I have absolutely no idea. Any help and advice would be greatly appreciated!
Error::
I've downloaded Microsoft JDBC driver 4.0 for SQL server. It contained two jar files sqljdbc and sqljdbc4. I added both the jar files to the above project.
I'm learning to build a database application using Netbeans IDE 7.2.1 and Microsoft SQL Server 2008 R2.
I found a basic program(the first step) to create a connection between the two. But I'm getting the following error.
I'm doing this for the first time so I have absolutely no idea. Any help and advice would be greatly appreciated!
/*
* Main.java
*
* Created on 16 de agosto de 2007, 04:38 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package TestPackage;
import java.sql.*;
/**
*
* @author maricelys
*/
public class Main
{
/** Creates a new instance of Main */
public Main()
{
}
/**
* @param args
* the command line arguments
*/
public static void main(String[] args)
{
// TODO code application logic here
try
{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String connectionUrl = "jdbc:sqlserver://localhost:1433;"
+ "databaseName=Northwind;user=sa;password=123456;";
Connection con = DriverManager.getConnection(connectionUrl);
System.out.println("Successful");
}
catch (SQLException e)
{
System.out.println("SQL Exception: " + e.toString());
}
catch (ClassNotFoundException cE)
{
System.out.println("Class Not Found Exception: " + cE.toString());
}
}
}
Error::
run: Dec 02, 2012 12:44:54 AM com.microsoft.sqlserver.jdbc.SQLServerConnection <init> SEVERE: Java Runtime Environment (JRE) version 1.7 is not supported by this driver. Use the sqljdbc4.jar class library, which provides support for JDBC 4.0. Exception in thread "main" java.lang.UnsupportedOperationException: Java Runtime Environment (JRE) version 1.7 is not supported by this driver. Use the sqljdbc4.jar class library, which provides support for JDBC 4.0. at com.microsoft.sqlserver.jdbc.SQLServerConnection.<init>(SQLServerConnection.java:304) at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1011) at java.sql.DriverManager.getConnection(DriverManager.java:579) at java.sql.DriverManager.getConnection(DriverManager.java:243) at TestPackage.Main.main(Main.java:39) Java Result: 1 BUILD SUCCESSFUL (total time: 0 seconds)
I've downloaded Microsoft JDBC driver 4.0 for SQL server. It contained two jar files sqljdbc and sqljdbc4. I added both the jar files to the above project.