资源简介
ssd7 答案全 quiz + excercise + exam 1 2 3 4 5 6 7 8 9 10

代码片段和文件信息
import java.util.*;
import java.io.*;
import java.text.*;
import java.sql.*;
/**
* A class representing the driver program to the
* SSD7 transaction exercise.
*
* @author CTE
* @version 1.0
*/
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:movie“;
String username = “vince“;
String password = ““;
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 );
// Create a statement object.
stmt = conn.createStatement();
// Begin a new chained transaction.
stmt.executeUpdate( “Begin Work“ );
// Set the transaction isolation level to serializable
stmt.executeUpdate( “set transaction isolation level serializable“ );
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
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 18994 2008-05-29 09:58 ssd7-ex10-65\indexes.txt
目录 0 2008-07-16 18:59 ssd7-ex10-65
----------- --------- ---------- ----- ----
18994 2
相关资源
- 数据库系统基础教程答案第三版机械
- 《数字信号处理第三版》课后习题答
- 数据结构年终考题范围和答案 耿国华
- 大学物理答案 同济大学 高等教育出版
- 信息论与编码(仇佩亮编著 高等教育
- 《复变函数》习题答案(第四版)
- 中科院 编译原理 习题及解答
- 西安电子科技大学 并行计算 霍红卫
- 浙江工业大学2005-2006学年单片机习题
- 信息系统分析与设计试卷及答案
- SSD4 exercise8答案
- 杨素行第三版模电答案
- 复变函数参考答案(西安交通大学版
- 复旦大学出版社 李贤平 《概率论基础
- 数值分析答案(第五版)李庆扬
- 数据结构殷人昆版的课后答案
- 郁道银 工程光学 习题答案
- 操作系统教程课后答案华中科技大学
- 用友ERP考试系统练习题库及答案
- 《原子物理学》高教 杨福家 完整版课
- 真正!!!概率论与数理统计浙江大
- 计算机操作系统课后_汤小丹_第四版
- 计算机操作系统(第四版)汤小丹课
- 南京大学考研845真题答案-2018
- Convex Optimization 习题答案
- 数据结构考研试题历届试卷(附答案
- 计算机网络自顶向下方法答案(第六
- 数学分析教材,复旦,陈传璋、金福
- 操作系统教程课后习题答案
- 编译原理龙书答案
评论
共有 条评论