Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1024717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:49:10+00:00 2026-05-16T11:49:10+00:00

I am new to Java and I am attempting to use JDBC to connect

  • 0

I am new to Java and I am attempting to use JDBC to connect to an UniVerse database. I’m using Sun Java 6 JDK to using NetBeans to build the project. My simple test below builds however it gives the errors below:

> run:
driver loaded
Exception in thread "main" java.lang.ExceptionInInitializerError
Connecting...
        at com.ibm.u2.jdbc.UniJDBCProtocolU2Impl.initDefaultMarks(UniJDBCProtocolU2Impl.java:1239)
        at com.ibm.u2.jdbc.UniJDBCProtocolU2Impl.<init>(UniJDBCProtocolU2Impl.java:116)
        at com.ibm.u2.jdbc.UniJDBCConnectionImpl.<init>(UniJDBCConnectionImpl.java:137)
        at com.ibm.u2.jdbc.UniJDBCDriver.connect(UniJDBCDriver.java:111)
        at java.sql.DriverManager.getConnection(DriverManager.java:582)
        at java.sql.DriverManager.getConnection(DriverManager.java:207)
        at testjdbc.Main.main(Main.java:36)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 3
        at asjava.uniclientlibs.UniTokens.<clinit>(UniTokens.java:109)
        ... 7 more
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)

My Test Code:

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package testjdbc;
import java.sql.*;
import java.io.*;

 /**
 *
* @author norm
 */
public class Main {

/**
 * @param args the command line arguments
 */
public static void main(String[] args) {

    Connection con = null ;

    try{
        // generate URL

    String url = "jdbc:ibm-u2://my.uv.db:31438/DB-ACCOUNT;user=me;password=pass"; //testing, I remove user and password from here and use them below. Still FAILS!!! ARGGGG!!!
    String user = "me";
    String password = "pass";

    String driver = "com.ibm.u2.jdbc.UniJDBCDriver";
    //Load driver and connect to server
    Class.forName(driver);
    System.out.println("driver loaded");
    System.out.println("Connecting...");
    con = DriverManager.getConnection(url); //This is line 36
    // con = DriverManager.getConnection(url, user, password); // gives the same error
    //con = DriverManager.getConnection("jdbc:ibm-u2://my.uv.db:31438/D:/PathTo/DB;" ); //and yet the same error for this as well
    System.out.println("Connection String sent");
    System.out.println("Querying...");
    testQuery( con ) ;

    }
    catch ( SQLException e ) {
        System.out.println("Ex-Message :" + e.getMessage());
        System.out.println("Ex-Code    :" + e.getErrorCode()) ;
        System.out.println("Ex-SQLState:" + e.getSQLState());
        System.out.println("Ex-Next    :" + e.getNextException());
        e.printStackTrace() ;
        System.gc();
  } catch ( Exception e) {
        System.out.println("Exception caught:"+e) ;
        e.printStackTrace() ;
  }
}

public static void testQuery(Connection con)
    throws SQLException
{
    Statement stmt = con.createStatement();
    String sql = "select FIRST.NAME from EMPCEL";
            //"select @ID, CITY, STATE, ZIP, PHONE from CUSTOMER";

    // Execute the SELECT statement
    ResultSet rs = stmt.executeQuery(sql);

    // Get result of first five records
    System.out.println("\tlist selected columns for the first five records:");
    int i = 1;
    while (rs.next() && i < 6)
    {
        System.out.println("\nRecord "+ i +" :");
        System.out.println("\tFirst Name : \t" + rs.getString(1));
//            System.out.println("\tCITY :\t" + rs.getString(2));
//            System.out.println("\tSTATE :\t" + rs.getString(3));
//            System.out.println("\tZIP : \t" + rs.getString(4));
//            System.out.println("\tPHONE :\t" + rs.getString(5));
        i++;
        System.out.println("Finished.");
    }

    rs.close();
    stmt.close() ;
    System.out.println("\n\t*--- QUERY test is done successful ---*\n");
}

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T11:49:11+00:00Added an answer on May 16, 2026 at 11:49 am

    This appears to be Netbeans related. See also this topic at their forum. It appears to work in Eclipse (and possibly all other environments).

    This is clearly a bug in the UniVerse JDBC driver. It is apparently inside the static initializer relying on some specific environmental condition, which is different in Netbeans. If it wasn’t a bug, it would have thrown a much more self-explaining exception, not such a silly runtime exception.

    I’d report this bug to IBM/UniVerse.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.