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

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

?? executesql.java

?? JAVA 2應用編程150例
?? 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一区二区三区免费野_久草精品视频
久久久99精品久久| 日韩欧美国产一区二区在线播放| 国内一区二区在线| 日本女优在线视频一区二区| 国产成人综合亚洲网站| 国模套图日韩精品一区二区| 老司机午夜精品99久久| 精品一区二区三区影院在线午夜| 久久激情五月激情| 国产精品一级黄| 91网址在线看| 欧美日韩成人综合| 亚洲精品欧美在线| 午夜精品久久久久| 亚洲久本草在线中文字幕| 久久色.com| 中文字幕中文字幕在线一区| 亚洲一区日韩精品中文字幕| 婷婷开心激情综合| 久久91精品国产91久久小草| 国产成人精品三级| 色综合久久99| 69堂成人精品免费视频| 国产三级精品在线| 亚洲黄色片在线观看| www.成人网.com| 欧美日韩一二三区| 国产精品网站导航| 午夜亚洲福利老司机| 精品一二线国产| 一本在线高清不卡dvd| 欧美精品在欧美一区二区少妇| 亚洲精品在线观看网站| 一级做a爱片久久| 国模套图日韩精品一区二区| 91美女在线观看| 欧美tickling网站挠脚心| 中文字幕在线不卡视频| 青草av.久久免费一区| 91在线观看美女| 精品奇米国产一区二区三区| 亚洲精品国产精华液| 精品亚洲免费视频| 欧美中文字幕一二三区视频| 国产欧美一区二区精品仙草咪| 亚洲成人先锋电影| 色综合一个色综合亚洲| 久久久精品蜜桃| 视频一区二区三区在线| 99久久综合国产精品| 欧美成人精品二区三区99精品| 亚洲欧美日韩成人高清在线一区| 久久激情综合网| 91精品国产欧美一区二区| 亚洲欧美另类图片小说| 高清在线成人网| 欧美tk丨vk视频| 日韩中文字幕不卡| 91视频免费看| 一区在线观看视频| 高清久久久久久| 久久久久久久久久久99999| 麻豆精品蜜桃视频网站| 91精品国模一区二区三区| 亚洲一区二区偷拍精品| 在线亚洲一区观看| 亚洲精品欧美激情| 99久久国产综合色|国产精品| 久久久精品综合| 国产精品综合网| 国产精品网站在线播放| 成人黄色a**站在线观看| 国产日韩欧美a| 高清成人免费视频| 日本一区二区三区视频视频| 国产自产高清不卡| 久久久精品欧美丰满| 成人午夜私人影院| 国产精品免费丝袜| 色一情一伦一子一伦一区| 亚洲精品伦理在线| 日本精品裸体写真集在线观看 | 欧美三级日韩三级国产三级| 中文字幕在线不卡视频| 99国产一区二区三精品乱码| 综合分类小说区另类春色亚洲小说欧美 | 日韩中文字幕不卡| 欧美tk—视频vk| 国产不卡视频在线观看| 国产精品美女久久久久久久久 | 亚洲午夜日本在线观看| 欧美日韩中文另类| 蜜臀av在线播放一区二区三区| 精品久久久久久久久久久久包黑料 | 狠狠色丁香久久婷婷综合丁香| 久久精品在线免费观看| 91在线云播放| 手机精品视频在线观看| 日韩精品一区二区在线观看| 国产不卡视频在线播放| 亚洲精品成人a在线观看| 91麻豆精品国产自产在线| 狠狠狠色丁香婷婷综合久久五月| 国产精品毛片久久久久久| 91小视频在线| 日韩二区在线观看| 久久久夜色精品亚洲| 色中色一区二区| 美脚の诱脚舐め脚责91| 中文字幕日韩精品一区| 91麻豆精品91久久久久同性| 国产91精品精华液一区二区三区| 亚洲最大成人网4388xx| 亚洲精品在线一区二区| 欧美在线观看视频一区二区| 国产美女在线精品| 午夜视频一区二区| 中文久久乱码一区二区| 欧美精品亚洲二区| 91免费在线看| 国产成人精品免费视频网站| 日韩二区在线观看| 中文字幕亚洲精品在线观看| 精品99久久久久久| 欧美综合久久久| 99精品国产一区二区三区不卡| 精东粉嫩av免费一区二区三区| 亚洲精品免费在线观看| 中文av一区特黄| 欧美xxx久久| 91精品久久久久久久久99蜜臂| 91丨porny丨在线| 国产精品123区| 激情综合色综合久久综合| 午夜精品久久久久久久蜜桃app| 中文字幕日韩一区| 国产精品久久久久久久久动漫| 欧美电视剧在线看免费| 91精品国产综合久久久久| 欧美亚洲丝袜传媒另类| 91女人视频在线观看| 盗摄精品av一区二区三区| 精品系列免费在线观看| 麻豆一区二区三区| 日本中文一区二区三区| 午夜成人免费视频| 亚洲成人综合网站| 一区二区在线看| 亚洲精品国产一区二区三区四区在线| 国产精品区一区二区三| 欧美激情中文不卡| 国产欧美日韩视频一区二区| 国产日韩欧美不卡在线| 久久精品一区四区| 国产日韩精品视频一区| 国产精品―色哟哟| 亚洲天堂网中文字| 亚洲精品高清在线| 香蕉久久一区二区不卡无毒影院| 性久久久久久久| 美女尤物国产一区| 国产一区二区三区黄视频| 国产91精品露脸国语对白| 99久久精品国产麻豆演员表| 色呦呦日韩精品| 在线不卡中文字幕播放| 日韩亚洲欧美在线| 久久青草欧美一区二区三区| 中日韩免费视频中文字幕| 亚洲精品乱码久久久久久久久| 亚洲国产精品一区二区www在线 | 国产欧美一区二区精品忘忧草| 国产精品午夜在线观看| 伊人婷婷欧美激情| 亚洲成人av在线电影| 久草在线在线精品观看| 丁香激情综合五月| 欧美日韩国产中文| 欧美电影免费观看高清完整版在| 国产视频不卡一区| 中文字幕一区在线| 日韩精品福利网| 国产成人免费av在线| 欧美三级视频在线| 亚洲精品一区二区三区精华液 | 日韩美女在线视频| 中文字幕一区二区日韩精品绯色| 亚洲午夜激情网页| 国产乱子伦视频一区二区三区| 99re8在线精品视频免费播放| 欧美丰满一区二区免费视频| 久久久久久电影| 肉色丝袜一区二区| 高清av一区二区| 欧美一区二区三区思思人| 国产精品乱码久久久久久| 日日夜夜免费精品视频| 盗摄精品av一区二区三区| 9191久久久久久久久久久| 中文字幕在线免费不卡|