1

I am writing an app to connect to a database on a server (AS400 server using SQL to talk to the database). IBM supplies a java toolbox to access the server in a jar called jt400android.

I have a test function:

protected void ConnectionTest()
{
      AS400 system = new AS400("jc400"); 
      try
      {
        system.connectService(AS400.RECORDACCESS);
      }
      catch(Exception e)
      {
        e.printStackTrace();
        System.exit(0);
      }
}

AS400 is a function included in the jt400android.jar in com.ibm.as400.access.* that handles socket protocol, connections, and authentication to an AS400 machine. (I've resorted to this method as JDBC is apparently not a good way to go).

The code compiles just fine, no errors or warnings, but when I run the apk on my AVD, I get this error

03-12 22:44:30.300: E/dalvikvm(484): Could not find class 'com.ibm.as400.access.AS400', referenced from method jcpaper.android.jc400droid.MainActivity.ConnectionTest

I've searched the forums and tried the following suggestions:

  1. added the jar to Java Build Path > Libraries (did this to make the code compile)
  2. checked jar on Java Build Path > Order and Export
  3. included a copy of the jar in [project folder]/libs

Each time I end up with the same could not find class error.

I'm running Eclipse for mobile (Juno v1) on Windows XP, building for Android 2.3.3.

Any suggestions on what's happening here?

James Allman
  • 40,573
  • 11
  • 57
  • 70
Sammy
  • 99
  • 1
  • 2
  • 10
  • add your external jar file into /libs folder of the android project and try building... – Sudar Nimalan Mar 13 '13 at 00:31
  • I did try that, but Davlik started yelling at me, telling me I was out of memory. – Sammy Mar 14 '13 at 19:03
  • It spit this out for each class until it crashed: Dx warning: Ignoring InnerClasses attribute for an anonymous inner class (com.ibm.as400.access.xxx) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is not an inner class – Sammy Mar 14 '13 at 23:29

1 Answers1

1

The JTOpen Lite/JTLite libraries might provide a better way of connecting to your server. These libraries are new from IBM and are designed for specific use on Android devices.

JTOpen Lite - IBM Developer Works

JTOpen Lite Javadoc

Make sure that you add the .jar to the build path and export the libraries properly.

The record level access method that you are trying to use is an older method for connecting applications to DB2 databases, so you will probably have a harder time finding information about it.

burtmacklin16
  • 715
  • 2
  • 13
  • 31
  • Thanks so much. You have no idea how nice it is to have some good documentation on this. I'm going to switch back to using jdbc. The AS400 class seems so archaic, but it was the only decent documentation I could find. It is building now and recognizing the jar. – Sammy Mar 21 '13 at 16:04