Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2013
    Posts
    1
    Rep Power
    0

    Default how to install and configure sqlserver jdbc driver type 4

    Please i really need help on how to install and configure sql server 2012 jdbc driver i have set my enviromental variables, i even set the classpath in the command prompt like this set CLASSPATH =.;C:\Users\T-BAM\Desktop\sqljdbc_4.0\enu\sqljdbc4.jar i tried to unzip it into my Program Files its giving an error message like could not create C:\Program Files\Microsoft SQL Server JDBC Driver\sqljdbc_4.0 - unzip operation cancelled i eventually created a folder in program files Microsoft SQL Server JDBC Driver and set the classpath like this set CLASSPATH =.; C:\Program Files\Microsoft SQL Server JDBC Driver\sqljdbc_4.0\enu\sqljdbc4.jar still not working or is anything wrong with my simple code which goes like this

    Please i really need help on how to install and configure sql server 2012 jdbc driver i have set my enviromental variables, i even set the classpath in the command prompt like this set CLASSPATH =.;C:\Users\T-BAM\Desktop\sqljdbc_4.0\enu\sqljdbc4.jar i tried to unzip it into my Program Files its giving an error message like could not create C:\Program Files\Microsoft SQL Server JDBC Driver\sqljdbc_4.0 - unzip operation cancelled i eventually created a folder in program files Microsoft SQL Server JDBC Driver and set the classpath like this set CLASSPATH =.; C:\Program Files\Microsoft SQL Server JDBC Driver\sqljdbc_4.0\enu\sqljdbc4.jar still not working or is anything wrong with my simple code which goes like this

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

    try
    {
    String str = "select * from dbo.Patient_registration";
    String connectionUrl = "jdbc:sqlserver://T-BAM-PC:1433;databaseName=GeneralHospital;user=sa;passw ord=godhelpme";
    Class.forName("com.microsoft.sqlserver.jdbc.SQLSer verDriver");
    Connection con = DriverManager.getConnection(connectionUrl);

    Statement stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery(str);
    System.out.println();

    while (rs.next())
    {
    int id = rs.getInt(1);
    String surtname = rs.getString(2);
    String firstname = rs.getString(3);
    String midlename = rs.getString(4);
    String regdate = rs.getString(5);
    String collectiondate = rs.getString(6);
    String report =rs.getString(7);
    String age = rs.getString(8);
    String sex = rs.getString(9);


    System.out.println(id +"\t" + surtname + "\t" + firstname +"\t" + midlename +"\t" + regdate + "\t" + collectiondate + "\t" + report + "\t" + age + "\t" + sex );
    }


    }
    catch(Exception ex)
    {
    System.out.println("Error occured");
    System.out.println("Error:"+ex);


    }// TODO add your handling code here:
    }

    after clicking the jButton1 it throws an exception : Error occured
    Error:java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
    I have read various articles to help my self still not working, I will so much appreciate it if anyone can help me solve this problem that is giving me sleepless night

    after clicking the jButton1 it throws an exception : Error occured
    Error:java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
    I have read various articles to help my self still not working, I will so much appreciate it if anyone can help me solve this problem that is giving me sleepless night

  2. #2
    jashburn is offline Senior Member
    Join Date
    Feb 2014
    Posts
    219
    Rep Power
    1

    Default Re: how to install and configure sqlserver jdbc driver type 4


  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,767
    Blog Entries
    7
    Rep Power
    21

    Default Re: how to install and configure sqlserver jdbc driver type 4

    It's even a double post in this single thread ;-)

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: how to install and configure sqlserver jdbc driver type 4

    How are you running that code?

    Do not set the CLASSPATH environment variable.
    You really don't want a global CLASSPATH like that. Besides, it will have no effect on executable jar files (hence my question about how you are running your code).

    You do not install a jar file. You simply stick it with your app, usually in a lib directory, and point the runtime classpath at it when you want to run your app. That last part takes me back to my first question...
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Replies: 5
    Last Post: 07-24-2013, 04:19 PM
  2. Replies: 5
    Last Post: 03-13-2012, 02:51 PM
  3. Replies: 0
    Last Post: 03-03-2012, 02:01 AM
  4. Replies: 1
    Last Post: 10-16-2008, 03:09 PM
  5. Replies: 1
    Last Post: 08-08-2007, 03:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •