HTTP Status 500 - Java Runtime Environment (JRE) version 1.7 is not supported by this driver

后端 未结 2 1953
梦毁少年i
梦毁少年i 2020-12-10 13:56

I am trying to access MS SQL server 2005 from a servlet file. I am using JDBC 4.0 driver. I have already added the JAR files sqljdbc.jar and sqljdbc4.jar<

相关标签:
2条回答
  • 2020-12-10 14:32

    Here is my Code to connect java to Microsoft sql Server 2012

    You only need sqljdbc4.jar that avail on offical Microsoft website. Here is the link:

    http://download.microsoft.com/download/0/2/A/02AAE597-3865-456C-AE7F-613F99F850A8/sqljdbc_4.0.2206.100_enu.exe

    It contains 2 jar files, and I am trying to use sqljdbc4.jar. This is the code I am using to connect:

    package com.Sql.ConnectDB;
    
    import java.sql.*;
    public class DbClass {
    
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            try{
                **String url="jdbc:sqlserver://localhost;databaseName=Student";**//important
                String user="username";
                String pass="password";
                **Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");**//important
                Connection con=DriverManager.getConnection(url,user,pass);
                System.out.println("Conneccted Successfully");
            }catch(Exception e){
                e.printStackTrace();
            }
        }
    
    }
    
    0 讨论(0)
  • 2020-12-10 14:46

    The error message is pretty clear. Tomcat is using the wrong driver.

    You state that you copied sqljdbc.jar and sqljdbc4.jar into the Tomcat lib folder. That is most probably the reason for your problem.

    You only need sqljdbc4.jar otherwise Tomcat picks up the wrong one.

    Try to delete sqljdbc.jar from the Tomcat lib folder

    0 讨论(0)
提交回复
热议问题