在eclipse中创建JavaWeb怎么连接Mysql?

http://img1.mukewang.com/5a6be2980001adb503140418.jpg

weibo_周子Xiao_0
浏览 1969回答 3
3回答

昵称已被禁用

用框架的话  直接在DB文件里面配置就行了

qq_无_奈_0

Connection con=null; Statement stat=null; ResultSet rs=null; try { Class.forName("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException e) { e.printStackTrace(); } try { con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root"); stat=con.createStatement();这是在servlet连接数据库的操作,需要四个属性,driver:com.mysql.jdbc.Driver,URL:jdbc:mysql://localhost:3306/test,username:你数据库设置的name,password:你数据库设置的密码

皇太极666

这要看你用的什么框架了,可以用jdbc百度一下,也没多少代码
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java
MySQL