连接网络上的数据库

my
盛洁 6 years ago
parent 8c9e35e668
commit edcc12fa02

@ -32,5 +32,5 @@ dependencies {
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation files('libs/mysql-connector-java-5.1.39-bin.jar') implementation files('libs\\mysql-connector-java-5.1.39-bin.jar')
} }

@ -15,11 +15,11 @@ public class DatabaseHelper {
public static Connection getConnection(){ public static Connection getConnection(){
String username = "root"; String username = "root";
String password =""; String password ="SJ1126388959";
if(conn==null){ if(conn==null){
try { try {
Class.forName("com.mysql.jdbc.Driver"); Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://172.18.22.77:3306/dogson?useSSL=true&characterEncoding=utf-8"; String url = "jdbc:mysql://139.180.223.93:3306/dogson?useSSL=true&characterEncoding=utf-8";
conn = DriverManager.getConnection(url,username,password); conn = DriverManager.getConnection(url,username,password);
return conn; return conn;
}catch(Exception e){ }catch(Exception e){

Loading…
Cancel
Save