).maven添加jar pom.xml 中添加
1). http://mvnrepository.com/,或者:https://search.maven.org/ 添加
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.47</version>
</dependency>
</dependencies>
2).直接下载jar包 在wepapp包下,创建lib文件夹 然后add as library
2.java 注册驱动
clas.forname("com.mydql.jdbc.driver");
Connection conn = drivermanager.getconnection("jdbc:mysql://localhost:3306/stu","root","wang");
3.执行sql语句;
string sql ="select * from account";
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sql);
4.