mysql基础笔记

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 ---;

posted @ 2012-10-13 10:24  竹简溪畔  阅读(148)  评论(0编辑  收藏  举报