亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? executesql.java

?? 這是一個應用CS數據庫的源碼,編寫精巧,便于學習.
?? JAVA
字號:
import java.sql.*;
import java.io.*;
/**
 * A general-purpose SQL interpreter program.
 **/
public class ExecuteSQL {
	public static void main(String[] args) {
		Connection conn = null; // Our JDBC connection to the database server
		try {
			String driver = null, url = null, user = "", password = "";
			// Parse all the command-line arguments
			for(int n = 0; n < args.length; n++) {
				if (args[n].equals("-d")) driver = args[++n];
				else if (args[n].equals("-u")) user = args[++n];
				else if (args[n].equals("-p")) password = args[++n];
				else if (url == null) url = args[n];
				else throw new IllegalArgumentException("Unknown argument.");
			}
			// The only required argument is the database URL.
			if (url == null)
				throw new IllegalArgumentException("No database specified");
			// If the user specified the classname for the DB driver, load
			// that class dynamically. This gives the driver the opportunity
			// to register itself with the DriverManager.
			if (driver != null) Class.forName(driver);
			// Now open a connection the specified database, using the
			// user-specified username and password, if any. The driver
			// manager will try all of the DB drivers it knows about to try to
			// parse the URL and connect to the DB server.
			conn = DriverManager.getConnection(url, user, password);
			// Now create the statement object we'll use to talk to the DB
			Statement s = conn.createStatement();
			// Get a stream to read from the console
			BufferedReader in =
				new BufferedReader(new InputStreamReader(System.in));
			// Loop forever, reading the user's queries and executing them
			while(true) {
				System.out.print("sql> "); // prompt the user
				System.out.flush(); // make the prompt appear now.
				String sql = in.readLine(); // get a line of input from user
				// Quit when the user types "quit".
				if ((sql == null) || sql.equals("quit")) break;
				// Ignore blank lines
				if (sql.length() == 0) continue;
				// Now, execute the user's line of SQL and display results.
				try {
					// We don't know if this is a query or some kind of
					// update, so we use execute() instead of executeQuery()
					// or executeUpdate() If the return value is true, it was
					// a query, else an update.
					boolean status = s.execute(sql);
					// Some complex SQL queries can return more than one set
					// of results, so loop until there are no more results
					do {
						if (status) { // it was a query and returns a ResultSet
						ResultSet rs = s.getResultSet(); // Get results
							printResultsTable(rs, System.out); // Display them
						}
						else {
							// If the SQL command that was executed was some
							// kind of update rather than a query, then it
							// doesn't return a ResultSet. Instead, we just
							// print the number of rows that were affected.
							int numUpdates = s.getUpdateCount();
							System.out.println("Ok. " + numUpdates +
								" rows affected.");
						}
						// Now go see if there are even more results, and
						// continue the results display loop if there are.
						status = s.getMoreResults();
					} while(status || s.getUpdateCount() != -1);
				}
				// If a SQLException is thrown, display an error message.
				// Note that SQLExceptions can have a general message and a
				// DB-specific message returned by getSQLState()
				catch (SQLException e) {
					System.err.println("SQLException: " + e.getMessage()+ ":" +
						e.getSQLState());
				}
				// Each time through this loop, check to see if there were any
				// warnings. Note that there can be a whole chain of warnings.
				finally { // print out any warnings that occurred
					SQLWarning w;
					for(w=conn.getWarnings(); w != null; w=w.getNextWarning())
					System.err.println("WARNING: " + w.getMessage() +
						":" + w.getSQLState());
				}
			}
		}
		// Handle exceptions that occur during argument parsing, database
		// connection setup, etc. For SQLExceptions, print the details.
		catch (Exception e) {
			System.err.println(e);
			if (e instanceof SQLException)
			System.err.println("SQL State: " +
				((SQLException)e).getSQLState());
			System.err.println("Usage: java ExecuteSQL [-d <driver>] " +
				"[-u <user>] [-p <password>] <database URL>");
		}
		// Be sure to always close the database connection when we exit,
		// whether we exit because the user types 'quit' or because of an
		// exception thrown while setting things up. Closing this connection
		// also implicitly closes any open statements and result sets
		// associated with it.
		finally {
			try { conn.close(); } catch (Exception e) {}
		}
	}

	/**
	 * This method attempts to output the contents of a ResultSet in a
	 * textual table. It relies on the ResultSetMetaData class, but a fair
	 * bit of the code is simple string manipulation.
	 **/
	static void printResultsTable(ResultSet rs, OutputStream output)
		throws SQLException
	{
		// Set up the output stream
		PrintWriter out = new PrintWriter(output);
		// Get some "meta data" (column names, etc.) about the results
		ResultSetMetaData metadata = rs.getMetaData();
		// Variables to hold important data about the table to be displayed
		int numcols = metadata.getColumnCount(); // how many columns
		String[] labels = new String[numcols]; // the column labels
		int[] colwidths = new int[numcols]; // the width of each
		int[] colpos = new int[numcols]; // start position of each
		int linewidth; // total width of table
		// Figure out how wide the columns are, where each one begins,
		// how wide each row of the table will be, etc.
		linewidth = 1; // for the initial '|'.
		for(int i = 0; i < numcols; i++) { // for each column
			colpos[i] = linewidth; // save its position
			labels[i] = metadata.getColumnLabel(i+1); // get its label
			// Get the column width. If the db doesn't report one, guess
			// 30 characters. Then check the length of the label, and use
			// it if it is larger than the column width
			int size = metadata.getColumnDisplaySize(i+1);
			if (size == -1) size = 30; // Some drivers return -1...
			if (size > 500) size = 30; // Don't allow unreasonable sizes
			int labelsize = labels[i].length();
			if (labelsize > size) size = labelsize;
			colwidths[i] = size + 1; // save the column the size
			linewidth += colwidths[i] + 2; // increment total size
		}
		// Create a horizontal divider line we use in the table.
		// Also create a blank line that is the initial value of each
		// line of the table
		StringBuffer divider = new StringBuffer(linewidth);
		StringBuffer blankline = new StringBuffer(linewidth);
		for(int i = 0; i < linewidth; i++) {
			divider.insert(i, '-');
			blankline.insert(i, " ");
		}
		// Put special marks in the divider line at the column positions
		for(int i=0; i<numcols; i++) divider.setCharAt(colpos[i]-1,'+');
		divider.setCharAt(linewidth-1, '+');
		// Begin the table output with a divider line
		out.println(divider);
		// The next line of the table contains the column labels.
		// Begin with a blank line, and put the column names and column
		// divider characters "|" into it. overwrite() is defined below.
		StringBuffer line = new StringBuffer(blankline.toString());
		line.setCharAt(0, '|');
		for(int i = 0; i < numcols; i++) {
			int pos = colpos[i] + 1 + (colwidths[i]-labels[i].length())/2;
			overwrite(line, pos, labels[i]);
			overwrite(line, colpos[i] + colwidths[i], " |");
		}
		// Then output the line of column labels and another divider
		out.println(line);
		out.println(divider);
		// Now, output the table data. Loop through the ResultSet, using
		// the next() method to get the rows one at a time. Obtain the
		// value of each column with getObject(), and output it, much as
		// we did for the column labels above.
		while(rs.next()) {
			line = new StringBuffer(blankline.toString());
			line.setCharAt(0, '|');
			for(int i = 0; i < numcols; i++) {
				Object value = rs.getObject(i+1);
				if (value != null)
					overwrite(line, colpos[i] + 1, value.toString().trim());
				overwrite(line, colpos[i] + colwidths[i], " |");
			}
			out.println(line);
		}
		// Finally, end the table with one last divider line.
		out.println(divider);
		out.flush();
	}
	
	/** This utility method is used when printing the table of results */
	static void overwrite(StringBuffer b, int pos, String s) {
		int slen = s.length(); // String length
		int blen = b.length(); // Buffer length
		if (pos+slen > blen) slen = blen-pos; // Does it fit?
		for(int i = 0; i < slen; i++) // Copy string into buffer
			b.setCharAt(pos+i, s.charAt(i));
	}
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91精品国产欧美一区二区成人| 日韩精品在线网站| 日韩午夜激情av| 国产精品色一区二区三区| 亚洲成精国产精品女| 国产精品 欧美精品| 91精品国产综合久久久久久久久久| 中文字幕乱码久久午夜不卡| 日产国产高清一区二区三区| av动漫一区二区| 国产亚洲欧美中文| 麻豆国产精品视频| 欧美日韩成人综合在线一区二区 | 欧美日韩亚洲高清一区二区| 久久综合久久99| 午夜伊人狠狠久久| 欧美在线视频日韩| 亚洲日本一区二区三区| 粉嫩高潮美女一区二区三区| 精品精品国产高清a毛片牛牛 | 天天av天天翘天天综合网色鬼国产| 国产精品一品二品| 精品盗摄一区二区三区| 蜜桃久久久久久久| 日韩一区和二区| 秋霞午夜av一区二区三区| 欧美日韩中文国产| 婷婷丁香激情综合| 欧美美女喷水视频| 丝袜美腿亚洲一区| 日韩亚洲欧美中文三级| 日韩电影一区二区三区四区| 欧美精品777| 日本中文在线一区| 欧美一区二区二区| 经典三级视频一区| 久久久影院官网| 国产不卡在线一区| 国产精品久久久久久久久图文区 | 国产欧美一区二区三区在线看蜜臀 | 亚洲国产精品天堂| 欧美视频中文字幕| 日韩av电影免费观看高清完整版 | 洋洋成人永久网站入口| 在线视频国产一区| 天堂在线一区二区| 日韩免费一区二区| 在线不卡一区二区| 日本在线不卡视频一二三区| 欧美一区二区三区免费观看视频| 免费在线观看精品| 国产亚洲精久久久久久| 一本在线高清不卡dvd| 一区二区三区丝袜| 日韩欧美一区二区视频| 国产99精品视频| 亚洲黄色免费网站| 欧美不卡一区二区| 成人的网站免费观看| 亚洲制服丝袜一区| 精品少妇一区二区三区日产乱码| 粉嫩av一区二区三区在线播放 | 337p粉嫩大胆噜噜噜噜噜91av| 国产一区二区三区黄视频| 国产精品久久久久久久久久久免费看 | 国产精品成人一区二区艾草| 欧美在线啊v一区| 美女视频黄 久久| 亚洲欧美综合色| 日韩女优电影在线观看| 99re这里只有精品视频首页| 日韩和欧美的一区| 国产精品免费观看视频| 欧美一区二区三区免费视频| 成人精品免费看| 日韩av一区二区在线影视| 久久精品亚洲精品国产欧美| 欧美视频在线一区二区三区| 国产成人av一区| 日本欧美一区二区| 亚洲欧美福利一区二区| 精品电影一区二区三区| 欧美日韩国产小视频| 风间由美一区二区av101| 爽爽淫人综合网网站| 国产精品乱码人人做人人爱| 日韩视频免费观看高清完整版在线观看 | 国产无遮挡一区二区三区毛片日本| 在线观看日韩一区| 成人av高清在线| 91女人视频在线观看| 美国av一区二区| 亚洲444eee在线观看| 亚洲欧洲无码一区二区三区| 久久影院电视剧免费观看| 欧美精品一卡两卡| 91国偷自产一区二区使用方法| 国产高清精品在线| 精品一区二区三区在线观看| 天堂精品中文字幕在线| 亚洲一区精品在线| 亚洲精品成人天堂一二三| 国产亚洲短视频| 久久午夜国产精品| 久久一日本道色综合| 在线不卡中文字幕| 欧美精品丝袜久久久中文字幕| 色综合久久久久综合体桃花网| 成人av资源网站| 成人国产亚洲欧美成人综合网| 韩国成人在线视频| 国产精品一区在线观看你懂的| 美国毛片一区二区三区| 青青草成人在线观看| 日韩不卡一区二区| 日本aⅴ亚洲精品中文乱码| 日韩高清一级片| 蜜臀av国产精品久久久久| 久久成人久久鬼色| 韩国精品主播一区二区在线观看| 久久精品国产一区二区三| 九九久久精品视频| 国产精品一区在线观看你懂的| 高清beeg欧美| 成人av网址在线观看| 色综合久久综合网| 欧美午夜精品久久久久久孕妇| 欧美巨大另类极品videosbest| 91精品国产高清一区二区三区| 欧美一级爆毛片| 国产亚洲精品福利| 中文字幕中文乱码欧美一区二区 | www.欧美日韩国产在线| 99久久精品费精品国产一区二区| 色综合久久天天| 91麻豆精品国产91久久久使用方法| 欧美一级午夜免费电影| 久久久久久久综合| 亚洲美腿欧美偷拍| 婷婷丁香久久五月婷婷| 国产一区二区三区精品欧美日韩一区二区三区| 国产一区二区三区久久悠悠色av| 懂色av一区二区三区蜜臀| 91电影在线观看| 欧美成人video| 成人免费在线视频| 免费在线观看一区| av电影在线观看一区| 51精品久久久久久久蜜臀| 国产日韩三级在线| 亚洲成a人v欧美综合天堂| 国产黄色精品视频| 欧美日韩第一区日日骚| 中文字幕精品一区二区精品绿巨人| 亚洲欧美一区二区三区极速播放| 热久久一区二区| 99久久久精品| 欧美精品一区二区三区在线播放 | 久久久精品日韩欧美| 亚洲精品乱码久久久久久黑人 | 久久综合色天天久久综合图片| 中文字幕一区二| 久久99国产乱子伦精品免费| 成人三级伦理片| 精品久久一区二区| 亚洲国产一区二区三区| 成人网男人的天堂| 日韩亚洲欧美一区| 亚洲综合免费观看高清完整版在线 | 高清不卡在线观看| 日韩三级视频中文字幕| 中文字幕亚洲成人| 精品在线亚洲视频| 欧美日韩视频在线第一区 | 一级精品视频在线观看宜春院 | 一本色道综合亚洲| 精品福利在线导航| 亚洲成人av一区二区三区| 99精品久久只有精品| 国产午夜精品一区二区三区视频 | 国产99精品在线观看| 欧美性xxxxx极品少妇| 国产精品丝袜在线| 国产传媒久久文化传媒| 日韩三级免费观看| 日韩—二三区免费观看av| 欧美日韩情趣电影| 一区二区三区电影在线播| 成人av电影在线网| 国产精品久久久久四虎| 国产成人精品aa毛片| 国产亚洲精久久久久久| 国产精品一二三区在线| 久久综合一区二区| 国产在线精品免费av| 精品日韩欧美一区二区| 久久99精品久久久久婷婷| 日韩三级免费观看| 国产综合久久久久影院| 久久久蜜桃精品|