首頁 >資料庫 >mysql教程 >jdbc-安卓新手用JDBC连接mysql时一直报错

jdbc-安卓新手用JDBC连接mysql时一直报错

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB原創
2016-06-06 09:34:321429瀏覽

mysqljdbc数据库android

抛出异常在logcat提示:驱动连接成功,数据库连接失败Could not find class 'javax.naming.StringRefAddr', referenced from method com.mysql.jdbc.ConnectionPropertiesImpl$ConnectionProperty.storeTo。求大神帮忙,错误围绕好长时间了

连接代码

<code> //连接数据库 public static Connection getCon() {  Connection conn = null;  try {   Class.forName("org.gjt.mm.mysql.Driver");   System.out.println("驱动连接成功");  } catch (ClassNotFoundException e1) {   // TODO Auto-generated catch block   System.out.println("驱动连接失败");  }     String dbUrl = "jdbc:mysql://localhost:3306/student";     String username = "root";     String psw = "1234";  try {   conn = DriverManager.getConnection(dbUrl,username,psw);  } catch (SQLException e) {   // TODO Auto-generated catch block   System.out.println("数据库连接失败"+e);  }  return conn; }</code>
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn