最近在用AndroidStudio连接云端服务器上的数据库。使用的是xampp,里面用的是mysql5.5
通过查看logcat发现是DriverManager.getconnection这句话的问题,但是不知道错在哪里
url里的ip地址是我在服务器里的cmd通过ipconfig得到的IPv4参数,这里我删掉了
用户名和密码也没有错,但就是不知道哪里有错
程序运行时不报错但是会显示:
下面是连接数据库的代码以及logcat,使用的是AndroidStudio
publicclassDBUtils{
privatestaticfinalStringTAG="DBUtils";
privatestaticStringurl="jdbc:mysql://172...:3306/jujia";
privatestaticStringuser="root";
privatestaticStringpwr="970819";
privatestaticConnectiongetConnection(){
Connectionconn=null;
Log.i("wzx","test1");
try{
Class.forName("com.mysql.jdbc.Driver");
Log.i("wzx","test2");
}catch(ClassNotFoundExceptione1){
Log.i("wzx","加载驱动失败");
e1.printStackTrace();
}
Log.i("wzx","classfornae");
try{
Log.i("wax","test3");
conn=DriverManager.getConnection(url,user,pwr);
Log.i("wzx","conntest");
}catch(SQLExceptione){
Log.i("wzx","failed");
}
Log.i("wzx","success");
returnconn;
}
publicstaticHashMapgetUserInfoByName(Stringname){
HashMapmap=newHashMap();
Log.i("wzx","beforeGetconnectiontest");
Connectionconn=getConnection();
try{
Statementst=conn.createStatement();
Stringsql="select*frommanagerwhereMID='"+name+"'";
ResultSetres=st.executeQuery(sql);
if(res==null){
returnnull;
}else{
intcnt=res.getMetaData().getColumnCount();
//res.last();introwCnt=res.getRow();res.first();
res.next();
for(inti=1;i --> |