csh:在$HOME/.cshrc中添加一下行
setenv JAVA_HOME/usr/java/jdk1.6.0
setenv PATH $JAVA_HOME/bin:$PATH
setenv CLASSPATH .
bash/ksh中:
在$HOME/.bash_profile中添加以下行:
JAVA_HOME=/home/tarena/jdk1.6.0_05
CLASSPATH=.:..:$JAVA_HOME/jre/lib/rt.jar(java类所在的目录或jar文件,在虚拟机中加载类时,虚拟机在CLASSPAHT中找到它)
PATH=$JAVA_HOME/bin:$PATH ( *** 作系统需要在PATH中找到它)
export JAVA_HOME CLASSPATH PATH
source .bash_profile 让全局环境变量.bash_profile生效
Connection conntry {
Class.forName("oracle.jdbc.driver.OracleDriver")
conn = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:taian", "hr", "hr")//连接Oracle
conn.setAutoCommit(false)
Statement myStat = conn.createStatement()
String sqlTxt = "update BankAccount set account=account-" + this.amount.getText() + " where accId=" + this.payOut.getText()
System.out.println("第一步 执行:" + sqlTxt)
// 从汇出方扣减
try {
int affectedRow = myStat.executeUpdate(sqlTxt)
System.out.println("从汇出方扣减" + this.amount.getText() + "元,修改了" + affectedRow + "行数据.")
sqlTxt = "update BankAccount set account=account+" + this.amount.getText() + " where accId=" + this.saveIn.getText()
System.out.println("第二步 执行:" + sqlTxt)
affectedRow = myStat.executeUpdate(sqlTxt)
System.out.println("从汇入方增加" + this.amount.getText() + "元,修改了" + affectedRow + "行数据.")
// 事务成功结束, 提交
conn.commit()
} catch (SQLException sqlEx) {
System.out.println("耶!语句写错了吧")
sqlEx.printStackTrace()
// 事务中断,整体回滚到事务开始前状态
conn.rollback()
}
// 汇入方增加帐户余额
myStat.close()
conn.close()
} catch (Exception ex) {
System.out.println("反正是出错了.")
}
}//
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)