资源简介
Programming with Transactions
Testing Commits and Rollbacks
Almost all commercial-strength DBMS software supports the ability to undo the effects of a transaction before those effects are committed to the database. This is particularly useful when an operation must be performed to completion or no
代码片段和文件信息
import java.util.*;
import java.io.*;
import java.text.*;
import java.sql.*;
/**
* A class representing the driver program to the
* SSD7 transaction exercise.
*
* @author CSSE 0902K Bek Zhuldyz
* @version 09.12.2011
*/
public class MovieTransaction
{
/**
* main method.
*
*/
public static void main( String [] args )
{
String [] movienames = new String[10];
String [] movietimes = new String[10];
String sqlquery = null;
String moviename = null;
String movietime = null;
ResultSet rset = null;
Connection conn = null;
Statement stmt = null;
BufferedReader keyIn = null;
String url = “jdbc:postgresql:zhuldyz“;
String username = “postgres“;
String password = “webuser“;
int position = 0 choice movie_id numseats availableseats;
try
{
// Create a BufferedReader to read input from the keyboard.
keyIn = new BufferedReader(new InputStreamReader(System.in));
// Load the PostgreSQL JDBC driver
Class.forName(“org.postgresql.Driver“);
// Create a connection to the database.
conn = DriverManager.getConnection( url usernamepassword );
// Turn off autocommit at each statement. We will manually commit.
// Set the transaction isolation level to serializable
//conn.setAutoCommit(false);
//conn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
// Create a statement object.
stmt = conn.createStatement();
System.out.println( “Welcome to the movie theater!“ );
// Query the titles currently playing.
String SQLQuery = “select distinct title from movie“;
rset = stmt.executeQuery( SQLQuery );
while( rset.next() )
{
movienames[rset.getRow()] = rset.getString( “title“ );
System.out.println( rset.getRow() + “: “ + rset.getString(“title“) );
}
// Ask the user what movie he wants to see.
System.out.print( “Enter the number of the movie you want to see:“ );
choice = Integer.parseInt(keyIn.readLine());
moviename = movienames[(choice)];
// Query the id for this movie.
sqlquery = new String( “select movie_id from movie where title=‘“ + moviename + “‘“ );
rset = stmt.executeQuery( sqlquery );
rset.next();
movie_id = rset.getInt( “movie_id“ );
// Query the available times for the chosen movie.
sqlquery = new String( “select distinct movie_time from showing where movie_id =“ + movie_id );
rset = stmt.executeQuery( sqlquery );
while( rset.next() ) {
movietimes[(rset.getRow())] = rset.getString( “movie_time“ );
System.out.println( rset.getRow() + “: “ + rset.getString( “movie_time“ ) );
}
// Ask the user what showing he wants to see.
System.out.println( “Enter the number of the time you want to see: “ );
choice = Integer.parseInt( keyIn.readLine() );
movietime = movietimes[(choice)];
// Ask the user how many seats he wants.
System.out.println( “Please enter the number of seats that you want to buy: “ );
numseats = Integer.parseInt( keyIn.readLine() );
//
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1065 2011-12-09 08:39 Ex 9\deadlock.txt
文件 1302 2011-12-09 08:05 Ex 9\isolation.txt
文件 4928 2011-12-09 09:39 Ex 9\MovieTransaction.java
文件 553 2011-12-10 22:39 Ex 9\rollback.txt
文件 15221 2011-12-09 09:04 Ex 9\Transactions at the ATM.docx
目录 0 2011-12-09 09:42 Ex 9
----------- --------- ---------- ----- ----
23069 6
- 上一篇:MIPS机器码翻译器(修正一)
- 下一篇:Flash兔子跳铃铛
相关资源
- J /ψ→γππ,γπ0&e
- 戴森-施温格方程在有限球体积中的手
- Intel(R) 82579V网卡驱动for server20033
- H310.B360.H370.Z390.USB WIN7 64位第三方驱动
- 使用FRS-ESR对储存的富含中子的129130
- asus华硕 m5a97 le r2.0主板bios 官方版
- ASUS华硕K45VD|A45VD主板驱动程序 v9.3.0
- 华硕ASUS K42JZ BIOS主板驱动程序 v9.1.1
- 基于STM32F4x9的LCD显示
- Samsung三星R439-DS系列网卡驱动程序 v
- 易语言查询79种快递源码
- 使用SPCE061A扩展K9F1208实现数码录音及
- 基于SPCE061A单片机的图形液晶模块的驱
- 数字正交上变频器AD9857在高频雷达系
- UPTool_Ver2090.rar
- eclipse_jetty9离线插件
- gi945解除限制pjbios
- 安国(ALCOR)AU9386主控U盘量产修复工
- ARM9指令cache的verilog代码
- 2019最新镜像工具,一键仿站
- 瑞芯微RK原厂3399+LPDDR4 200球参考原理图
- IBM Rational Software Architect 9.0破解文件
- 用AD6、AD9画完PCB生成gerber文件详细说
- TMC2209中文手册.pdf
- 2019程序员互联网公司最新面经包含腾
- Symantec AntiVirus 9.0防病毒客户端部署注
- Einstein-Maxwell-Dilaton-Axion模型中的剪切
- stk9.0破解文件
- Visual Assist X 通用破解补丁v2.0 适用于
- VisualSVN-VS2019-7.1.2破解版
评论
共有 条评论