0
我知道有一些人在這裏有關於此問題。我已閱讀了其中的一些,但沒有任何解決方案來幫助我。錯誤:沒有合適的驅動程序jdbc在android studio
我已經包含在我的應用程序的build.gradle庫:
apply plugin: 'com.android.application'
android {
...
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.microsoft.azure.android:azure-storage-android:[email protected]'
compile 'com.android.support:design:23.1.1'
compile files('libs/mysql-connector-java-5.0.8/mysql-connector-java-5.0.8-bin.jar')
}
我在該項目中的build.gradle類路徑:
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'com.google.gms:google-services:1.3.0-beta1'
classpath 'mysql:mysql-connector-java:5.0.8'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
我在庫文件夾下的lib:
]
,我已經implimented讓司機在我的計劃:
String hostName = "whereyaatserver.database.windows.net";
String dbName = "whereyaatdatabase";
String user = "Capstone_Admin";
String password = "Swde4321!";
String url = "jdbc:sqlserver://whereyaatserver.database.windows.net:1433;database=whereyaatdatabase;[email protected];password=Swde4321!;encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;";
Connection connection = null;
public Mapping() throws SQLException {
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mapping);
try {
Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection(url);
} catch (SQLException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
,我添加了一個變量CLASSPATH環境變量點到我的lib文件夾:
]
我不能完全肯定我要去的地方錯了。我明顯在某種原因,但我不確定我是否犯了一個小錯誤,或者以完全錯誤的方式進行。任何指導將不勝感激。
好,最好的答案是「不要在Android應用程序中使用JDBC」。你的'CLASSPATH'沒有意義,因爲那是Windows,而你正在編寫一個在Android上運行的應用程序。而你的'url'似乎是用於SQL Server的,而你的驅動程序似乎是用於MySQL的。 – CommonsWare
如果不使用sql,使用Azure的android數據庫的最佳方式是什麼? – Ontarianmm
我不能說Azure。除此之外,通常我們在與數據庫交談的服務器上使用某種形式的Web服務,移動應用程序與Web服務交談。 – CommonsWare