Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Java & Ms Sql

Options
  • 14-03-2006 6:10pm
    #1
    Closed Accounts Posts: 216 ✭✭


    Hi,

    It's been a while since I programmed Java and I'm trying to compile the file below, but keep getting the follow error:

    Exception in thread "main" java.lang.NoClassDefFoundError: java/util/logging/Logger
    at com.microsoft.sqlserver.jdbc.Util.<clinit>(Unknown Source)
    at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at Query1.main(Query1.java:12)

    It seems to be a problem with "Connection con = DriverManager.getConnection.." line. Could this happen if java.sql is not properly imported, or would the file even compile?

    Any ideas?

    Cheers Gogul

    import java.sql.*;

    class Query1
    {
    public static void main(String[] args)
    {
    try
    {
    Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
    Connection con = DriverManager.getConnection("jdbc:sqlserver://localhost;databaseName=DB;user=name;password=pass");
    String SQL = "SELECT TOP 1 messageText FROM requestLog";
    Statement stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery(SQL);

    while (rs.next())
    {
    String messageText= rs.getString("messageText");
    System.out.println(messageText);
    }
    con.close();
    }
    catch (Exception e)
    {
    System.err.println("Got an exception! ");
    System.err.println(e.getMessage());
    }
    }
    }


Comments

  • Registered Users Posts: 1,996 ✭✭✭lynchie


    You are using a minimum of 1.4 JDK? The java.util.logging package was only added in that version. Running it with a 1.3 or 1.2 jdk will cause those issues.


  • Closed Accounts Posts: 216 ✭✭gogul


    lynchie wrote:
    You are using a minimum of 1.4 JDK? The java.util.logging package was only added in that version. Running it with a 1.3 or 1.2 jdk will cause those issues.

    Yeah, I think that was it, alright. I installed 1.5 JDK and its working now. Cheers for your help.

    gogul


Advertisement