与Android的ADT为JTDS MS SQL [英] JTDS for MS SQL in android with ADT

查看:277
本文介绍了与Android的ADT为JTDS MS SQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,也许这可能是一个重新发布:尝试使用JTDS在Android项目,不知道,但似乎有在该职位无人接听i'll尝试在这里,问题是,我尝试通过连接到MS SQL 2K5
JTDS(虽然JTDS连接就好了,我试了一个纯粹的Java测试
并能成功地在Android上ADT(日食)连接),并不能发现在类路径中得到典型的异常ClassNotFoundException的班级,因为我没有这个问题遇到我做了所有我知道解决这个问题(除了运行程序之前通过以java命令命令行,因为我不知道该怎么做,与Dalvik的,所以我设置类路径
通过构建路径日食选项,把罐子在库/,失败获得例外,我擦除库所有的罐子/并通过构建路径选项删除所有的罐子,清理项目,并重新启动月食XXX次后,重新设置罐,仍然得到了同样的异常,仍悬而未决;通过Windows CLASSPATH变量配置varible,任何其他的想法家伙?

first of all maybe this could be a repost of: Trying to use jtds in Android Project, not sure, but seems there's no answer in that post i´ll try it here, issue is, im trying to connect to a MS SQL 2k5 via JTDS (though the JTDS connection is just fine, i tried it on a pure java test and could connect successfully) on android with ADT (eclipse) and it can't found the class in classpath getting the typical Exception ClassNotFoundException, as i did encounter with this problem before i did all i know for solve it (except for running the program via command line with "java -cp" , cause i don't know how to do that with dalvik, so i set the classpath via "build path" eclipse option, put the jar at libs/, after xxx times of failure getting the exception i erase all the jars in libs/ and remove all the jars via "build path" option, clean the project and restart eclipse, set up jars again, still got the same exception, still pending; configuring the varible via windows classpath variable, any other ideas guys?

软件:
Windows 7专业版32位
JDK 1.7
ADT日食
JTDS 1.3(最新现在在他们的网页)
MS SQL 2K5
安卓4.2.2

Software: Windows 7 professional 32 bits jdk 1.7 ADT eclipse jtds 1.3 (latest by now in their web page) MS SQL 2k5 android 4.2.2

请注意:如果需要code,要求它(我不认为是必要的,同时code运行完美无瑕
在通过与同JTDS的NetBeans)的纯Java。

note: if need the code, ask for it (i don't think is necessary, same code runs flawless in pure java via netbeans with the same jtds).

推荐答案

看起来这是一个很难的话题触碰(没有答案的原因)无论如何,我解决这个问题,在这里我会离开它一步一步来。

seems like this is a hard topic to touch (cause of no answer) anyway, i solve the problem, here i will leave it step by step.

1:安装MS SQL 2K5(注意把混合(AUTH窗口和SQL用户DB访问/通和extrictly放了SA用户的密码,这是必须的)的

1: install MS SQL 2k5 (be aware of put the db access on mixed (window auth and SQL user/pass and extrictly put a password for SA user this is mandatory)

2:安装MS SQL Management Studio中(如果你想使事情变得更加容易,这是可选的),通过图形用户界面来创建数据库,并证明你正在插入的内容(或任何你正在做的DB)与Android设备真正被完成。

2: install MS SQL management studio (if you want to make things more easy, this is optional) to create database via GUI and prove that what you are inserting (or whatever you are doing to DB) with the android device is really being done.

3:配置MS SQL,请访问:SQL Server配置管理; SQL防爆preSS协议; TCP / IP协议
在已启用,以是第一个选项卡(协议)提出,然后在IP选项卡,把IPv4向已启用是,启用是在IPALL ipv2把TCP端口1433。

3: configure your MS SQL, go to: SQL server configuration manager; SQL Express protocols; TCP/IP in the first tab (protocol) put "enabled" to yes, then in the IP tab, put ipv4 to enabled YES, ipv2 enabled to yes and at IPALL put TCP port to 1433.

4:现在去你的JTDS-1.2.x的-dist的文件夹,如果32位操作系统的情况下,64到输入86(64话
文件夹),那么SSO和复制ntlmauth.dll你JDK /箱或JRE / bin文件夹。

4: now go to your jtds-1.2.x-dist folder and enter to x86 (if 32 bits OS in case 64 then x64 folder) then SSO and copy ntlmauth.dll to you jdk/bin or jre/bin folder.

5:我不会在这里贴上我的所有code,但字符串连接是一件重要的事情:

5: i won't paste all my code here but the String connection is an important thing:

conn = DriverManager.getConnection("jdbc:jtds:sqlserver://192.168.3.67:1433/androiddb", "sa", "1013")

6:注意,用于从Android设备连接ip是ipv2而不是IPv4缺省127.0.0.1或本地主机,如果你使用任何的它不会工作的,使用ipv2版本

6: be aware that the ip used for connecting from an android device is the ipv2 and not the ipv4 default 127.0.0.1 or localhost if you use any of those it won't work, use the ipv2 version.

我测试这从一个真实的Andr​​oid设备,正是三星Galaxy Tab,如果从尝试
模拟器也许你必须使用10.0.2.2的ip,不知道这个,因为我没有测试,多了一个重要的事情,由我写了这个1.3.0 JTDS并不适用于Android 4.2的工作时间,这就是为什么我说在JTDS一步看你JTDS-1.2.x的 - 距离,必须通过现在使用的1.2.x版本。

i test this from a real android device, exactly the samsung galaxy tab, if you try it from an emulator maybe you must use the 10.0.2.2 ip, not sure about this since i didn't test it, one more important thing, by the time i wrote this 1.3.0 jtds wasn't working for android 4.2, that's why i said in jtds step to look at your jtds-1.2.x-dist, you must use 1.2.x version by now.

希望这是有帮助的人,至于

hope this to be helpful to anyone, regards.

这篇关于与Android的ADT为JTDS MS SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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