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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Java & Ms Sql

  • 14-03-2006 5: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 Posts: 2,013 ✭✭✭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