无法通过Android的测试连接到SQL Server [英] Cannot connect to Sql Server via Android Test

查看:286
本文介绍了无法通过Android的测试连接到SQL Server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已创建了 UiAutomator 简单的Andr​​oid测试。在这些测试中,我要确认在数据库中添加一些数据。

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

在我的电脑我可以连接到数据库,但在虚拟的Andr​​oid设备,我得到了以下错误:

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

抛出java.lang.ClassNotFoundException:找不到类
  在路径net.sourceforge.jtds.jdbc.Driver:
  /system/framework/android.test.runner.jar:/system/framework/uiautomator.jar::/data/local/tmp/Tests.jar

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

在加载驱动程序时:

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

我怎么能告诉设备在哪里可以找到驱动程序?
我要上传在设备中的 jdts = 1.3.0.jar 地方?

我已经看了很多文章是这是可能的。但在我的情况下,code未在Android应用程序运行,但运行作为应用程序的测试。莫非是这个问题?

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

推荐答案

尝试把驱动jar的 libs目录的probject内,然后干净,再建
这可能帮助!

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

更新1
您可以访问这个答案,看看如何使用添加里面的库* .jar文件的蚂蚁

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

这篇关于无法通过Android的测试连接到SQL Server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆