Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
325 views
in Technique[技术] by (71.8m points)

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

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 files to my Tomcat /lib folder.

But while running code I am getting an error

HTTP Status 500 - 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.

How is this caused and how can I solve it?

My code is:

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection conn = conn =   DriverManager.getConnection("jdbc:sqlserver://localhost;databaseName=school;user=sa;password=123");
PrintWriter pwOut = res.getWriter();
pwOut.println("Connected");
Statement st = conn.createStatement();
String searchCriteria = req.getParameter("txtSearch");
ResultSet rs = st.executeQuery("select * from student");
res.setContentType("text/html");
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...