Cannot connect to Sql Server via Android Test

≯℡__Kan透↙ 提交于 2019-12-12 00:50:48

问题


I have created simple android tests with UiAutomator. In these tests I want to confirm that some data were added in the database.

In my pc I can connect to the database, but in the virtual android device I get the following error:

java.lang.ClassNotFoundException: Didn't find class "net.sourceforge.jtds.jdbc.Driver" on path: /system/framework/android.test.runner.jar:/system/framework/uiautomator.jar::/data/local/tmp/Tests.jar

when loading the driver:

Class.forName("net.sourceforge.jtds.jdbc.Driver");

How can I tell the device where to find the driver? Should I upload the jdts=1.3.0.jar somewhere in the device?


I have read many articles in the web were this is possible. But in my case the code is not running in an android app but runs as a test for the app. Could that be the problem?

Many SO answers suggest to implement it in an external service but I really don't want that for many reasons


回答1:


Try put the driver jar on the libs directory inside the probject and then clean and build again this may help!!

Update 1 You can visit this answer to see how to add *.jar files inside libs using ant

https://stackoverflow.com/a/1821912/716865



来源:https://stackoverflow.com/questions/16300711/cannot-connect-to-sql-server-via-android-test

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!