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

📄 yoursqlcmd.java

📁 原创的DBMS 数据库! 功能很简单
💻 JAVA
字号:
package code;
import java.io.*;
import java.sql.*;
import java.net.*;
import java.util.*;
public class yourSQLCmd {

	/**
	 * @param args
	 */
	static Vector tableList;
	public static void main(String[] args) throws IOException,SQLException{
		// TODO Auto-generated method stub
		String inputstring;
		 BufferedReader stdin,loadFileReader;
	      BufferedReader startReader=(BufferedReader)null;
		Connection con;
	    Statement stmt;
	    String fName,tableName=null,inputString,cmdString,colTypeName,dbType,
	      parameterString,loadString,fieldString,readString;
	    StringBuffer lineOut,prepareBuffer,valuesBuffer,inputBuffer;
	      boolean echo=false;
	      stdin = new BufferedReader(new InputStreamReader(System.in));
	    try
	      {
	         Class.forName("code.yourSQLDriver");
	      } catch (ClassNotFoundException e) {
	         System.err.println(
	              "JDBC Driver could not be registered!!\n");
	      }
	      
	      fName = ".";
	      if ( args.length > 0 ) fName = args[0];
	      
	            con = dbConnect(fName);
	            if ( con == (Connection)null )
	            {
	               fName = ".";
	               con = dbConnect(fName);
	            }
	            stmt = con.createStatement();
//	            for(int ttt=0;ttt<1;ttt++)
//	            {
//		            inputstring=stdin.readLine();
//		            stmt.executeUpdate(inputstring);
//	            }
	            String sql="select name age from bjj ;";
	            ResultSet rs=stmt.executeQuery(sql);
	            while(rs.next())
	            {
	            	System.out.println(rs.getString("name"));
	            	System.out.println(rs.getInt("age"));
	            	
	            }
	            
	            	
	}
	
	private static Connection dbConnect(String tinySQLDir) throws SQLException
	   {
	      Connection con=null;
	      DatabaseMetaData dbMeta;
	      File conPath;
	      File[] fileList;
	      String tableName;
	      ResultSet tables_rs;
	      conPath = new File(tinySQLDir);
	      fileList = conPath.listFiles();
	      if ( fileList == null )
	      {
	         System.out.println(tinySQLDir + " is not a valid directory.");
	         return (Connection)null;
	      } else {
	         System.out.println("Connecting to " + conPath.getAbsolutePath());
	         con = DriverManager.getConnection("jdbc:yourSQL:" + conPath, "", "");
	      }
//	      dbMeta = con.getMetaData();
//	      tables_rs = dbMeta.getTables(null,null,null,null);
//	      tableList = new Vector();
//	      while ( tables_rs.next() )
//	      {
//	         tableName = tables_rs.getString("TABLE_NAME");
//	         tableList.addElement(tableName);
//	      }
//	      if ( tableList.size() == 0 )
//	         System.out.println("There are no tinySQL tables in this directory.");
//	      else
//	         System.out.println("There are " + tableList.size() + " tinySQL tables"
//	         + " in this directory.");
	      return con;
	   }

}

⌨️ 快捷键说明

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