title: Android application connecting to an as400 database
body: <p>I'm trying to get my Android connected to my as400 server. Unfortunately when I click on My Connexion button, the driver isn't loaded and I don't know why.</p>
  
  <p>Here my is code:</p>
  
  <pre><code>package hello.world;
  
  import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.SQLException;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.view.View;
  
  
  public class HelloworldActivity extends Activity {
      /** Called when the activity is first created. */
  
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
      }
  
  
      public void Connexion(View view) throws SQLException {
          System.out.println("Tentative de connexion à la base de donnée."); //Connexion 
          String driver = "com.ibm.as400.access.AS400JDBCDriver";
  
          String url = "jdbc:as400://BEAUFIX;transaction isolation=read uncommitted;date format=iso;naming=system;libraries=*LIBL";   
          Connection conn = null;
          String userName = "GMAOBD60";
          String password = "GMAOBD60";
  
          try {
            Class.forName(driver).newInstance();
            conn = DriverManager.getConnection(url,userName,password);
            System.out.println("Connected to the database"); 
            conn.close();
            System.out.println("Disconnected from database");
          } catch (Exception e) {
            e.printStackTrace();
            System.out.println("ERROR");
  
  }
  }
  }
  </code></pre>
  
  <p>Here is my xmd code: </p>
  
  <p><code>&lt;Button
          android:id="@+id/Connexion"
          android:layout_width="196dp"
          android:layout_height="wrap_content"
          android:layout_marginLeft="50dp"
          android:layout_marginTop="100dp"
          android:text="@string/Connexion" android:layerType="hardware"
      android:onClick="Connexion" /&gt;</code></p>
  
  <p>And here is my error log:</p>
  
  <pre><code>06-05 07:18:56.100: W/System.err(564): java.lang.ClassNotFoundException: com.ibm.as400.access.AS400JDBCDriver
  06-05 07:18:56.155: W/System.err(564):  at java.lang.Class.classForName(Native Method)
  06-05 07:18:56.180: W/System.err(564):  at java.lang.Class.forName(Class.java:217)
  06-05 07:18:56.212: W/System.err(564):  at java.lang.Class.forName(Class.java:172)
  06-05 07:18:56.241: W/System.err(564):  at hello.world.HelloworldActivity.Connexion(HelloworldActivity.java:33)
  06-05 07:18:56.271: W/System.err(564):  at java.lang.reflect.Method.invokeNative(Native Method)
  06-05 07:18:56.290: W/System.err(564):  at java.lang.reflect.Method.invoke(Method.java:511)
  06-05 07:18:56.321: W/System.err(564):  at android.view.View$1.onClick(View.java:3039)
  06-05 07:18:56.340: W/System.err(564):  at android.view.View.performClick(View.java:3511)
  06-05 07:18:56.371: W/System.err(564):  at android.view.View$PerformClick.run(View.java:14105)
  06-05 07:18:56.371: W/System.err(564):  at android.os.Handler.handleCallback(Handler.java:605)
  06-05 07:18:56.380: W/System.err(564):  at android.os.Handler.dispatchMessage(Handler.java:92)
  06-05 07:18:56.391: W/System.err(564):  at android.os.Looper.loop(Looper.java:137)
  06-05 07:18:56.391: W/System.err(564):  at android.app.ActivityThread.main(ActivityThread.java:4424)
  06-05 07:18:56.401: W/System.err(564):  at java.lang.reflect.Method.invokeNative(Native Method)
  06-05 07:18:56.410: W/System.err(564):  at java.lang.reflect.Method.invoke(Method.java:511)
  06-05 07:18:56.421: W/System.err(564):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
  06-05 07:18:56.431: W/System.err(564):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
  06-05 07:18:56.431: W/System.err(564):  at dalvik.system.NativeStart.main(Native Method)
  06-05 07:18:56.441: W/System.err(564): Caused by: java.lang.NoClassDefFoundError: com/ibm/as400/access/AS400JDBCDriver
  06-05 07:18:56.460: W/System.err(564):  ... 18 more
  06-05 07:18:56.460: W/System.err(564): Caused by: java.lang.ClassNotFoundException: com.ibm.as400.access.AS400JDBCDriver
  06-05 07:18:56.481: W/System.err(564):  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
  06-05 07:18:56.492: W/System.err(564):  at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
  06-05 07:18:56.492: W/System.err(564):  at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
  06-05 07:18:56.500: W/System.err(564):  ... 18 more
  </code></pre>
  
  <p>Also I've tried many things but I always came to an error. Help me please I want this to work :(</p>
  
  <p>And no I didn't forget to import my jt400.jar which is the "com.ibm.as400.access.AS400JDBCDriver"</p>
  
  <p>Thank you in advance,
  Aurelian</p>