background image

八、网络编程

TCP/IP 协议

九、数据库编程

1、中间层(M)

操作系统

2、计算机中的系统

文件系统

数据库系统

3、Oracle、Mysql
4、schema:约束

5

连接数据库步骤:

1、加载驱动(Class.forName(“com.mysql.jdbc.Driver”)

——

);

写在

static 中

2、建立链接(Connection con=

DriverManager.getConnection(url,username,passw

ord));

url====jdbc:mysql://localhost:3306/数据库
username====root;

password====root;

3、创建能执行 sql 的语句。

Statement stmt=conn.creatStatement ();

4、执行 sql 语句

stmt.executeUpdte (sql);

5、(执行查询结果);

6、关闭资源。

stmt.close ();

con.close ();

6

提高操作数据库的性能

1、PreparedStatement 与 Statement,利用 PreparedStatement 进行预编

译。

2、

……

建立连接时

3、及时关闭数据库(rs、stmt、con)。

try

{

if(rs!=null)

{

rs.close ();

}

}

catch()
{}

finally
{

try
{

if (rs!=null)
{

stmt.close 

();

}

}

catch ()
{}

finally
{

if (rs!=null)
{

con.close 

();

}

}

}

7.

1、Try——catch 中的代码尽量少。

2、尽晚拿到连接,尽早释放。

7、面向接口编程;

8、Object …
9、数据库中每张表的字段应少于 30 个、每张表应有一个主键、表结构中的字段应

预留 2

……

个(防止

)。

10、索引:(相当于书中的目录)。

11、Oracle:sequence