This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Journey To Enterprise Agility and have Daryl Kulak & Hong Li on-line!
See this thread for details.
Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Joe Ess

connecting to a SQL database or ODBC DSN  RSS feed

Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I get this error when trying to connect to a particular :
SQLException: No suitable driver found for jdbc:sqlserver:// 08001VendorError: 0

here is the code how do I make this work am I missing the driver?

<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.* " %>
<%@ page import="*" %>
try {
String driver = "org.sqlserver.Driver";
String url = "jdbc:sqlserver://";
String username = "user";
String password = "<fakepassword>";
String myDataField = null;
String myQuery1 = "SELECT  uid,student_sid from d_student;";
String myQuery = "SELECT  uid,student_sid from d_student;";
Connection myConnection = null;
PreparedStatement myPreparedStatement = null;
ResultSet myResultSet = null;
myConnection = DriverManager.getConnection(url,username,password);
myPreparedStatement = myConnection.prepareStatement(myQuery);
myResultSet = myPreparedStatement.executeQuery();

if ((request.getParameter("sd") != null) || (request.getParameter("ed") != null))
  if (request.getParameter("excel") != null)
   response.setHeader("Content-Disposition", "attachment; filename=MSmult_table.csv");
   out.println("AuditID,object Type Id,Object Id,User Name,Action Type ID,Action Success ID,Time Stamp") ;
   while (
     out.println(myResultSet.getString("uid") + "," + myResultSet.getString("stuednt_sid"));
  out.println("Hello <b>"+request.getParameter("name")+"</b>!");
  out.println("Hello <b>Select a date range and click submit to generate list of logins for the time span</b>!");

catch(ClassNotFoundException e){e.printStackTrace();}
catch (SQLException ex)
out.print("SQLException: "+ex.getMessage());
out.print("SQLState: " + ex.getSQLState());
out.print("VendorError: " + ex.getErrorCode());
Posts: 3596
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have the driver deployed with your webapp?

That aside (and I expect you'll say you've been told to do it like this) but you shouldn't have Java code in a JSP page like that.
That should be handled via a servlet, probably calling a service, which then gathers the data you need.  That is then passed onto the JSP page which simply has to handle displaying the result.

Also, you might want to look into connection pools for whatever server you are using, later on.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!