Home > Database > Mysql Tutorial > jdbc-安卓新手用JDBC连接mysql时一直报错

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

WBOY
Release: 2016-06-06 09:34:32
Original
1421 people have browsed it

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>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template