Myeclipse连接mysql小程序案例
来源:互联网 发布:矩阵正交化有什么用 编辑:程序博客网 时间:2024/05/17 21:49
package Mysql;
import java.sql.*;
//连接数据的
public class MysqlConnection {
public static void main(String[] args) {
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try {
Class.forName("com.mysql.jdbc.Driver");//
conn = DriverManager.getConnection("" +
"jdbc:mysql://localhost/mydata?user=root&password=123456");//连接地址,用户名和密码;
stmt = conn.createStatement();//连接状态;
rs = stmt.executeQuery("select * from dept");
while (rs.next()) {
System.out.println(rs.getString("deptno"));
}
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
} catch (SQLException ex) {
System.out.println("SQLException:" + ex.getMessage());
System.out.println("SQLState:" + ex.getStackTrace());
System.out.println("VendorErro:" + ex.getErrorCode());
} finally {
try {
if (rs != null) {
rs.close();
rs = null;
}
if (stmt != null) {
stmt.close();
stmt = null;
}
if (conn != null) {
conn.close();
conn = null;
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
- Myeclipse连接mysql小程序案例
- Myeclipse连接oracle小程序案例
- myeclipse连接mysql遇到的小问题
- python连接mysql简单小程序
- 电话录音小程序案例
- MYSQL :小案例金山词霸
- jsp连接mysql案例
- MyEclipse连接数据库MySQL
- myeclipse连接不到mysql
- MyEclipse连接MySQL
- Myeclipse连接Mysql!
- Myeclipse连接MySQL数据库
- MyEclipse 连接MySQL数据库
- myeclipse连接配置mysql
- Myeclipse连接mysql数据库
- myeclipse连接mysql数据库
- myeclipse连接mysql
- MyEclipse连接MySQL------Day0419
- ajax兼容问题代码
- 解决:System.Data.SqlClient.SqlException: 超出了存储过程、函数、触发器或视图的最大嵌套层数(最大层数为 32).
- Storm源码阅读之SpoutOutputCollector
- ADAS高级驾驶辅助系统
- IO编程
- Myeclipse连接mysql小程序案例
- 数据库的设计
- JAVA多线程售票问题
- 使用Java Arrays类进行数组排序
- Java HashMap HashTable
- sybase数据库中时间类型转换以及比较
- Xcode_7 iOS_9 获取设备型号 Objective-C (5)
- select 1,import,insert into 2016.08.18回顾
- IONIC 自定义插件使用aar