⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testtablepopulate.java

📁 java2 primer plus一书源程序
💻 JAVA
字号:
/* * TestTablePopulate.java * * Created on December 27, 2001, 10:25 AM */package ch19;import java.sql.*;/** * * @author  Stephen Potts * @version */public class TestTablePopulate{        /** Creates new TestTablePopulate */    public TestTablePopulate()    {    }        public static void main(String[] args)    {        String createStatement;        try        {            //load the driver class            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");                        //Specify the ODBC data source            String sourceURL = "jdbc:odbc:TicketRequest";                        //get a connection to the database            Connection dbConn =            DriverManager.getConnection(sourceURL);                        //If we get to here, no exception was thrown            System.out.println("The database connection is " + dbConn);                                   //Create the statement            Statement statement1 = dbConn.createStatement();            String insertStatement;                                  //Add the information            insertStatement = "INSERT INTO TicketRequest VALUES(" +                     " 13, 'Beasley', 'Demarcus', 3001, "            + "'Caribbean', 'Miami', '1/1/2004', '3')";            statement1.executeUpdate(insertStatement);             //Add the information            insertStatement = "INSERT INTO TicketRequest VALUES(" +                     " 17, 'Glance', 'Harvey', 3001, "            + "'Caribbean', 'Miami', '1/1/2004', '3')";            statement1.executeUpdate(insertStatement);             //Add the information            insertStatement = "INSERT INTO TicketRequest VALUES(" +                     " 29, 'White', 'Byron', 20010, "            + "'South America', 'San Juan', '10/3/02', '3')";            statement1.executeUpdate(insertStatement);             //Add the information            insertStatement = "INSERT INTO TicketRequest VALUES(" +                     " 1001, 'Carter', 'Joesph', 2001, "            + "'Alaska', 'Vancouver', '1/1/1993', '3')";            statement1.executeUpdate(insertStatement);             //Add the information            insertStatement = "INSERT INTO TicketRequest VALUES(" +                     " 12345, 'Cocomo', 'Joe', 3001, "            + "'Caribbean', 'Miami', '1/1/2004', '3')";            statement1.executeUpdate(insertStatement);                        System.out.println("Table TicketRequest populated");            //Flush and close            dbConn.close();                    }catch(ClassNotFoundException cnfe)        {            System.err.println(cnfe);        }        catch (SQLException sqle)        {            System.err.println(sqle);        }        catch (Exception e)        {            System.err.println(e);        }    }//main}//class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -