如何MySQL JDBC驱动程序到Android工作室 [英] How to Mysql JDBC Driver to android studio
本文介绍了如何MySQL JDBC驱动程序到Android工作室的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想连接到通过JDBC远程SQL数据库
我在Android工作室工作
但在执行时,我得到这个错误
抛出java.lang.ClassNotFoundException:com.mysql.jdbc.Driver
所以,我如何添加JDBC驱动程序到Android工作室??
解决方案
- 下载JDBC 并提取的的.jar 的文件
- 开启Android的工作室和你感兴趣的项目
- 打开你的左侧面板中,在一,项目的标签
- 右键点击您的应用程序模块文件夹,然后转至的新的>的模块的并有选择 导入.JAR / .AAR包装的
- 在第一个字段必须插入pviously提取 的.jar 的文件中的$ P $的目录。您可以通过点击最右边的图标有三个点浏览你的文件夹 (...)的
一旦你选择了 的.jar 的文件和你的项目的同步的你可以移动到下一个步骤:
- 右键你的应用程序文件夹中的模块再次点击,选择的打开模块设置的
- 在新打开的窗口的左侧导航窗格中,转到类别的模块的并选择 应用的,然后在 依赖的标签。
- 有点击绿色加号( + 的),并选择 模块依赖的。选择的的mysql 的模块。
- 单击的确定的,然后关闭所有打开的窗口。 A 同步的过程应该发生一次。
- 如果一切都已经做得正确,你的应用程序模块的文件夹的你应该看到的使用mysql-connector-java的的模块文件夹下。
- 请不要忘记,包括你在code想要的类。
故障排除结果
在我而言,我不得不卸载模块并重新安装。原因是该模块与Java 1.8,而不是1.7(目前由Android版本工作室支持:1.5.1)编译。
I want to connect to remote sql database via jdbc I work on Android Studio But when executing I got this error
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
So How can I add The JDBC Driver to Android Studio ??
解决方案
- Download JDBC and extract the .jar file
- Open Android Studio and your project of interest
- Open your Left Panel, in the 1.Project Tab
- Right Click on your application module folder and go to New > Module and there Select Import .JAR/.AAR Package.
- In the first field you must insert the directory of the previously extracted .jar file. You can browse your folders by clicking on the far right icon with the 3 dots (...)
Once you have selected the .jar file and your project Synchronizes you can move on to the next steps:
- Right Click again on your application module folder and select Open Module Settings
- In the left navigation pane of the newly opened window, go to the category Modules and select app and then the Dependencies tab.
- There click on the green plus (+), and select Module Dependencies. Select the mysql module.
- Click OK, and close all the opened windows. A Synchronization process should take place once more.
- If everything has been done correctly, under your app module folder you should see a mysql-connector-java module folder.
- Don't forget to include the classes you want in your code.
Troubleshooting
In my case I had to uninstall the module and re-install it. The reason was that the module was compiled with Java 1.8 instead of 1.7 (currently supported by Android Studio ver:1.5.1).
这篇关于如何MySQL JDBC驱动程序到Android工作室的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文