资源简介
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
相关资源
- 大学英语 读写教程课后习题答案1-4册
- 计算机组成与设计课后答案ppt
- 江苏大学885程序设计编程题答案
- 近世代数初步(第二版)课后习题答
- 可变分区存储管理[附答案]
- 《高等代数》题库1 有详细的答案
- 数字通信原理(第二版)配套习题答
- 管理信息系统(第四版)-课后答案
- 数值计算课后习题答案
- 单片机期末考试题目及答案详解
- TCPIP协议族 第四版答案1~16章
- 通信原理英文版 樊昌信 英文答案
- 信息学奥赛一本通课后练习答案汇总
- 《实变函数论》课后答案
- 计算机网络考试题含答案
- 计算机组成原理习题答案_袁春风_wo
- GRE填空机经1200答案修正版本.pdf
- 软件工程导论(第五版)_(张海藩
- 操作系统\\操作系统习题及答案
- 软件测试技术基础课后习题答案_朱少
- C网络应用编程(第2版)课后答案.z
- UML系统建模基础教程第2版课后习题答
- 计算机网络第七版答案
- 计算机组成原理课后习题答案(第五
- 商务智能复习题目(含答案)
- 北邮2018年803考试试题参考答案分享版
- 密码编码学与网络安全(第四版)课
- 编译原理答案陈文宇、王晓斌
- 数字信号处理包括试题与答案和程序
- dsp答案离散时间信号处理双语版答案
评论
共有 条评论