class not found exception in android -


i using following code sqlconnection in android:

public void queryresultset(string commandsql) throws classnotfoundexception, java.sql.sqlexception     {          resultset rs;         connection conn = null;              toast msg1 = toast.maketext(getbasecontext(),                     "name = " + commandsql, toast.length_long);             msg1.show();               class.forname("net.sourceforge.jtds.jdbc.driver");              string username="14graficali\\administrator";              string connurl="jdbc:jtds:sqlserver://14graficali\\mssqlserver2008;databasename=dvdkiosk;user=14graficali\\administrator;instance=sqlexpress";              conn = drivermanager.getconnection(connurl);              statement st=conn.createstatement();             rs=st.executequery(commandsql);             while(rs.next())             {                  toast msg2 = toast.maketext(getbasecontext(),                         "name = " + rs.getstring("username"), toast.length_long);                 msg2.show();             }      } 

i have included net.sourceforge.jtds.jdbc.driver can see below :

enter image description here

stack trace:

08-20 10:57:42.087: w/system.err(400): java.lang.classnotfoundexception: net.sourceforge.jtds.jdbc.driver 08-20 10:57:42.087: w/system.err(400):  @ java.lang.class.classforname(native method) 08-20 10:57:42.087: w/system.err(400):  @ java.lang.class.forname(class.java:234) 08-20 10:57:42.087: w/system.err(400):  @ java.lang.class.forname(class.java:181) 08-20 10:57:42.087: w/system.err(400):  @ com.example.registrationapp.login.queryresultset(login.java:93) 08-20 10:57:42.087: w/system.err(400):  @ com.example.registrationapp.login$1.onclick(login.java:126) 08-20 10:57:42.087: w/system.err(400):  @ android.view.view.performclick(view.java:2485) 08-20 10:57:42.087: w/system.err(400):  @ android.view.view$performclick.run(view.java:9080) 08-20 10:57:42.087: w/system.err(400):  @ android.os.handler.handlecallback(handler.java:587) 08-20 10:57:42.087: w/system.err(400):  @ android.os.handler.dispatchmessage(handler.java:92) 08-20 10:57:42.098: w/system.err(400):  @ android.os.looper.loop(looper.java:123) 08-20 10:57:42.098: w/system.err(400):  @ android.app.activitythread.main(activitythread.java:3683) 08-20 10:57:42.098: w/system.err(400):  @ java.lang.reflect.method.invokenative(native method) 08-20 10:57:42.098: w/system.err(400):  @ java.lang.reflect.method.invoke(method.java:507) 08-20 10:57:42.098: w/system.err(400):  @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:839) 08-20 10:57:42.098: w/system.err(400):  @ com.android.internal.os.zygoteinit.main(zygoteinit.java:597) 08-20 10:57:42.098: w/system.err(400):  @ dalvik.system.nativestart.main(native method) 08-20 10:57:42.098: w/system.err(400): caused by: java.lang.noclassdeffounderror: net.sourceforge.jtds.jdbc.driver 08-20 10:57:42.107: w/system.err(400):  ... 16 more 08-20 10:57:42.107: w/system.err(400): caused by: java.lang.classnotfoundexception: net.sourceforge.jtds.jdbc.driver in loader dalvik.system.pathclassloader[/data/app/com.example.registrationapp-1.apk] 08-20 10:57:42.107: w/system.err(400):  @ dalvik.system.pathclassloader.findclass(pathclassloader.java:240) 08-20 10:57:42.107: w/system.err(400):  @ java.lang.classloader.loadclass(classloader.java:551) 08-20 10:57:42.107: w/system.err(400):  @ java.lang.classloader.loadclass(classloader.java:511) 

please me.

if have added jtds-1.2.5 driver, good. otherwise:

right click on project > properties > libraries tab add jtds-1.2.5.jar file clicking on "add external jars"

next, in order , export tab (right next libraries in java build path window) check box jtds-1.2.5.jar (and other external jars might have).

this export .jar containing driver .apk file.


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -