Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Java & Ms Sql

  • 14-03-2006 06: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, Registered Users 2, Paid Member Posts: 2,032 ✭✭✭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