mysql基础笔记
发布时间:2016-09-30 16:28:31 所属栏目:MySql教程 来源:网络整理
导读:1、mysql的安装图解。 2、不同数据库的区别对程序的影响 1)数据类型 2)分页的问题 sql的分页相当简单,不同数据库的分页是不同的。sql server也比较简单,只
|
1、mysql的安装图解。 2、不同数据库的区别对程序的影响 1)数据类型 2)分页的问题 sql的分页相当简单,不同数据库的分页是不同的。sql server也比较简单,只有oracle比较难一些。 3)数据库的自动递增字段 3、mysql的日期处理 4、连上java连上mysql验证实例:
import java.sql.*;
public class testmysqlconnection {
/**
* @param args
*/
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/mstx?user=root&password=123456");
stmt = conn.createStatement();
rs = stmt.executeQuery("select * from mstx_head");
while (rs.next()) {
System.out.println(rs.getString("tname"));
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException ex) {
System.out.println("SQLException:" + ex.getMessage());
System.out.println("SQLState:" + ex.getSQLState());
System.out.println("VendorError:" + 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();
}
}
}
}
5、英文文档,个人害怕,不敢动造成的。找例子程序 6、show databases、show tables; 注意: 在建表之前,必须要在前边加上use ---; URL:http://www.bianceng.cn/database/MySQL/201609/50447.htm (编辑:佛山站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
站长推荐
热点阅读


