07 2012 档案
摘要:JDBC---作用:连接数据库!1.首先new 一个驱动进行注册,这里实在DriverManager中自动注册,我们只需要new一个实例出来就好.2.从DriverManager中取得连接Connection.3.取得连接后进行数据库操作.Statement, PreparedStatement, CallableStatement. 通过Connection的方法获得.4.读取数据库用的ResultSet, 之后扩展了游标可来回滚动的数据集,以及可更新的结果集.5.关于Transaction, 首先手动关闭Connection的AutoCommit, 然后直接transaction中的数据库
阅读全文
摘要:1.将Connection的Auto commit改成false.-->Connetion conn; conn.setAutoCommit(false);2.执行需要在这次交易中完成的操作语句.3.手动commit--->conn.commit();4.将Connection的Auto commit改回true.-->conn.setAutoCommit(true);5.抓Exception,如果出错.conn.rollback(); 并且conn.setAutocommit(true);
阅读全文
摘要:We have noticed that it's very inconvenient to use class Statement to execute aSQL statement.So we have another solution which is PreparedStatement.PreparedStatement ps=conn.prepareStatement("...... ");ps.setInt(... , ...);ps.setString(... , ....);....thenps.execute();--->It's e
阅读全文
摘要:import java.sql.*; public class TestJDBC { public static void main(String[] args) throws Exception{ //1. Load the Driver //->1 Class.forName()|Class.forNmae().newInstance()|new DriverName() //->2 实例化时自动向DriverManager注册,不需要显示调用DriverManager.registerDriver方法 Class.forName("oracle.jdbc.drive
阅读全文
摘要:JDBC 连接参数: Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1522:ORCL", "scott","tiger");由于我机子上有home_1和home_2,home_2用的端口号是1522..所以这里是1522.服务名及端口号的问题在Oracle Net Manager中可以看到今天用sqlplus登录oracle数据库,一直用scott账号登录不成功.显示:“ORA-01034 -Oraclenot available”和
阅读全文
摘要://In the last version I have finish the function to write a line ...
//This version 0.2 will add more fun things... import java.awt.*;
import javax.swing.*;
import java.awt.event.*; public class DrawPad extends Frame { IDrawPad idp; JButton b1; JButton b2; JPanel jpl; public void init() { ...
阅读全文
摘要:思路:1.创建一个Frame作为载体画图.2.Frame中添加鼠标事件.3.创建一个容器ArrayList,用来存放鼠标点击的点.4.每当鼠标点击时就生成一个Point对象,将Point对象添加到一个容器ArrayList中去.然后重画界面.5.重画时用重新调用Paint方法.Paint方面中一次用Iterator遍历所以的Point点对象,然后将他们一次画出.import java.util.*;
import java.awt.*;
import java.awt.event.*; public class TestPaint { public static void main(Str..
阅读全文