TestPrepStmt(24)
来源:互联网 发布:linux 总线驱动 编辑:程序博客网 时间:2024/05/21 08:59
/**
*Title:TestPreStmt
*Description:
*@Copyright:
*@Company:
*@autor:firefly
*@version:1.0
*@time:2012.10.30
*/
import java.sql.*;
public class TestPrepStmt {
static PreparedStatement pstmt = null;
static Connection conn = null;
public static void main(String[] args) {
if (args.length != 3) {
System.out.println("Parameter Error! Please Input Again!");
System.exit(-1);
}
int deptno = 0;
try {
deptno = Integer.parseInt(args[0]);
} catch (NumberFormatException e) {
System.out.println("Parameter Error! Deptno should be Number Formeter!");
System.exit(-1);
}
String dname = args[1];
String loc = args[2];
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection("jdbc:oracle:thin:@122.207.171.222:1521:ORCL", "scott", "tiger");
pstmt = conn.prepareStatement("insert into dept2 values(?, ?, ?)");//注意下面几行和TestDML.java中相关语句的区别。
pstmt.setInt(1, deptno);
pstmt.setString(2, dname);
pstmt.setString(3, loc);
pstmt.executeUpdate();
} catch(ClassNotFoundException e) {
e.printStackTrace();
} catch(SQLException e) {
e.printStackTrace();
} finally {
try {
if(pstmt != null) {
pstmt.close();
pstmt = null;
}
if(conn != null) {
conn.close();
conn = null;
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
- TestPrepStmt(24)
- [Java] JDBC 03 TestPrepStmt.java
- 24
- 24
- 24
- 24
- 24
- 24
- 24
- 24
- 24
- 24
- 24
- 24
- 24
- 24
- 24
- 2010.5.24-2012.5.24
- mfc 利用HBITMAP 和CBITMAP 显示位图文件
- 带姓名的成绩单(字符数组版)
- 嵌入式系统是发展先进制造业的关键
- wampserver 网站访问非常缓慢的问题.
- Explore block module in Drupal
- TestPrepStmt(24)
- C++ Debug指针错误的说明
- TimePicker在ScrollView中滑动冲突的解决方法(更新适用于全控件的方法)
- 传工信部酝酿APP备案制 开发者称操作性不强
- [Leetcode] Permutations II
- Windows 7如何还原字体的默认设置
- 优秀程序员不得不知道的20个位运算技巧
- Asp.Net中List泛型数组的参数传递和遍历(示例源码)
- TestProc(25)