Java Database Programming Bible- P6
Số trang: 50
Loại file: pdf
Dung lượng: 1.40 MB
Lượt xem: 26
Lượt tải: 0
Xem trước 5 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
Java Database Programming Bible- P6: Welcome to Java Database Programming Bible. This book is for readers who are alreadyfamiliar with Java, and who want to know more about working with databases. The JDBCApplication Programming Interface has made database programming an importantaspect of Java development, particularly where Web applications are concerned.
Nội dung trích xuất từ tài liệu:
Java Database Programming Bible- P6 Chapter 7:Retrieving Data with SQL Queries * CREATE statements */ class TableQueryFrame extends JInternalFrame{ protected JTable table; protected JScrollPane tableScroller; protected JTextArea SQLPane = new JTextArea(); protected JButton queryButton = new JButton(Execute Query); protected DatabaseUtilities dbUtils; protected String tableName = null; protected String colNames[] = null; protected String dataTypes[] = null; protected String SQLQuery = null; protected String SQLCommandRoot = ; Y FL public TableQueryFrame(String tableName, DatabaseUtilities dbUtils){ AM System.out.println(tableName+, +dbUtils); setSize(600,400); setLocation(10,10); TE setClosable(true); setMaximizable(true); setIconifiable(true); setResizable(true); getContentPane().setLayout(new BorderLayout()); this.tableName=tableName; this.dbUtils=dbUtils; setTitle(Query +tableName); init(); setVisible(true); } // initialize the JInternalFrame private void init(){ -249 - Team-Fly®Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. Chapter 7:Retrieving Data with SQL Queries colNames = dbUtils.getColumnNames(tableName); dataTypes = dbUtils.getDataTypes(tableName); SQLQuery = SELECT TOP 5 * FROM +tableName; Vector dataSet = dbUtils.executeQuery(SQLQuery); table = createTable(colNames,dataSet); JScrollPane sqlScroller = new JScrollPane(SQLPane); tableScroller = new JScrollPane(table); JSplitPane splitter = new JSplitPane(JSplitPane.VERTICAL_SPLIT, sqlScroller,tableScroller); splitter.setDividerLocation(100); getContentPane().add(splitter,BorderLayout.CENTER); getContentPane().add(queryButton,BorderLayout.SOUTH); queryButton.addActionListener(new ButtonListener()); } protected JTable createTable(String[] colNames,Vector dataSet){ int nRows = dataSet.size(); String[][] rowData = new String[nRows][colNames.length]; for(int i=0;i Chapter 7:Retrieving Data with SQL Queries viewport.add(table); } } } Changes to the DBManager class (Listing 7-4) are once again minimal, amounting to no more than adding the hooks for the menu. Listing 7-4: DBManager package jdbc_bible.part2; import java.awt.*; import java.awt.event.*; import java.util.Vector; import javax.swing.*; import javax.swing.event.*; public class DBManager extends JFrame{ JMenuBar menuBar = new JMenuBar(); JDesktopPane desktop = new JDesktopPane(); String database = null; String tableName = null; String menuSelection = null; TableBuilderFrame tableMaker = null; TableEditFrame tableEditor = null; // added for Chapter 6 TableQueryFrame tableQuery = null; // added for Chapter 7 DatabaseUtilities dbUtils = null; TableMenu tableMenu = new TableMenu(); EditMenu editMenu = new EditMenu(); // added for Chapter 6 ViewMenu viewMenu = new ViewMenu(); // added for Chapter 7 MenuListener menuListener = new MenuListener(); public DBManager(){ -251 -Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. Chapter 7:Retrieving Data with SQL Queries setJMenuBar(menuBar); setTitle(Java Database Bible); getC ...
Nội dung trích xuất từ tài liệu:
Java Database Programming Bible- P6 Chapter 7:Retrieving Data with SQL Queries * CREATE statements */ class TableQueryFrame extends JInternalFrame{ protected JTable table; protected JScrollPane tableScroller; protected JTextArea SQLPane = new JTextArea(); protected JButton queryButton = new JButton(Execute Query); protected DatabaseUtilities dbUtils; protected String tableName = null; protected String colNames[] = null; protected String dataTypes[] = null; protected String SQLQuery = null; protected String SQLCommandRoot = ; Y FL public TableQueryFrame(String tableName, DatabaseUtilities dbUtils){ AM System.out.println(tableName+, +dbUtils); setSize(600,400); setLocation(10,10); TE setClosable(true); setMaximizable(true); setIconifiable(true); setResizable(true); getContentPane().setLayout(new BorderLayout()); this.tableName=tableName; this.dbUtils=dbUtils; setTitle(Query +tableName); init(); setVisible(true); } // initialize the JInternalFrame private void init(){ -249 - Team-Fly®Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. Chapter 7:Retrieving Data with SQL Queries colNames = dbUtils.getColumnNames(tableName); dataTypes = dbUtils.getDataTypes(tableName); SQLQuery = SELECT TOP 5 * FROM +tableName; Vector dataSet = dbUtils.executeQuery(SQLQuery); table = createTable(colNames,dataSet); JScrollPane sqlScroller = new JScrollPane(SQLPane); tableScroller = new JScrollPane(table); JSplitPane splitter = new JSplitPane(JSplitPane.VERTICAL_SPLIT, sqlScroller,tableScroller); splitter.setDividerLocation(100); getContentPane().add(splitter,BorderLayout.CENTER); getContentPane().add(queryButton,BorderLayout.SOUTH); queryButton.addActionListener(new ButtonListener()); } protected JTable createTable(String[] colNames,Vector dataSet){ int nRows = dataSet.size(); String[][] rowData = new String[nRows][colNames.length]; for(int i=0;i Chapter 7:Retrieving Data with SQL Queries viewport.add(table); } } } Changes to the DBManager class (Listing 7-4) are once again minimal, amounting to no more than adding the hooks for the menu. Listing 7-4: DBManager package jdbc_bible.part2; import java.awt.*; import java.awt.event.*; import java.util.Vector; import javax.swing.*; import javax.swing.event.*; public class DBManager extends JFrame{ JMenuBar menuBar = new JMenuBar(); JDesktopPane desktop = new JDesktopPane(); String database = null; String tableName = null; String menuSelection = null; TableBuilderFrame tableMaker = null; TableEditFrame tableEditor = null; // added for Chapter 6 TableQueryFrame tableQuery = null; // added for Chapter 7 DatabaseUtilities dbUtils = null; TableMenu tableMenu = new TableMenu(); EditMenu editMenu = new EditMenu(); // added for Chapter 6 ViewMenu viewMenu = new ViewMenu(); // added for Chapter 7 MenuListener menuListener = new MenuListener(); public DBManager(){ -251 -Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. Chapter 7:Retrieving Data with SQL Queries setJMenuBar(menuBar); setTitle(Java Database Bible); getC ...
Tìm kiếm theo từ khóa liên quan:
bảo mật cơ sở dữ liệu cơ sở dữ liệu Mysql cơ sở dữ liệu sql cơ sở dữ liệu oracle giáo trình cơ sở dữ liệuTài liệu có liên quan:
-
62 trang 422 3 0
-
Giáo trình Cơ sở dữ liệu: Phần 2 - TS. Nguyễn Hoàng Sơn
158 trang 319 0 0 -
Giáo trình Cơ sở dữ liệu: Phần 2 - Đại học Kinh tế TP. HCM
115 trang 188 0 0 -
Giáo trình Cơ sở dữ liệu: Phần 1 - Sở Bưu chính Viễn Thông TP Hà Nội
48 trang 187 1 0 -
Giáo Trình về Cơ Sở Dữ Liệu - Phan Tấn Quốc
114 trang 132 1 0 -
Giáo trình Cơ sở dữ liệu (Ngành: Công nghệ thông tin - Trung cấp) - Trường Cao đẳng Xây dựng số 1
49 trang 113 0 0 -
Giáo trình cơ sở dữ liệu quan hệ_3
26 trang 110 0 0 -
54 trang 73 0 0
-
134 trang 69 1 0
-
0 trang 64 0 0
Tài liệu mới:
-
3 trang 1 0 0
-
giáo án vật lý 11 - định luật ôm đối với các loại mạch điện
5 trang 0 0 0 -
Đề thi thử THPT Quốc gia năm học 2017 - 2018 môn Toán - Trường THPT Chuyên Bắc Ninh - Mã đề 601
6 trang 0 0 0 -
Đề thi thử tốt nghiệp THPT môn Địa lí - THPT chuyên Nguyễn Bỉnh Khiêm
4 trang 1 0 0 -
Đề thi thử tốt nghiệp THPT môn Sinh - Sở GD&ĐT Yên Bái năm 2013 đề 121
7 trang 1 0 0