1 Replies - 2692 Views - Last Post: 03 December 2012 - 07:48 AM Rate Topic: -----

#1 aquafatz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 23-September 12

SQL server-Netbeans connection establishment error

Posted 01 December 2012 - 11:57 PM

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!

/*
 * 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.

Is This A Good Question/Topic? 0
  • +

Replies To: SQL server-Netbeans connection establishment error

#2 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10185
  • View blog
  • Posts: 37,603
  • Joined: 27-December 08

Re: SQL server-Netbeans connection establishment error

Posted 03 December 2012 - 07:48 AM

Moved to Java.

The error message is pretty clear. You can't use Java 7 with this driver.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1