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

📄 conntest4.java

📁 b树实现源码,linux和unix下运行,速度快,极好用
💻 JAVA
字号:
//Test 100 statements simultaneously in one connection , insert 1 tuple from
//each stmt, and check whether 100 tuples are inserted.
//Author: XieLiang
import java.sql.*;
public class ConnTest4 
{
    public static void main(String[] args) 
    {
       try
       {
           Class.forName("csql.jdbc.JdbcSqlDriver");
           Connection con = DriverManager.getConnection("jdbc:csql", "root", "manager");
           Statement cStmt = con.createStatement();
	   int ret =0;
           cStmt.execute("CREATE TABLE T1 (f1 integer, f2 char (20));");

           PreparedStatement stmt[] = new PreparedStatement[100];;
	   for (int i=0; i <100 ; i++)
	   {      
               stmt[i] = con.prepareStatement("INSERT INTO T1 VALUES (?, ?);");
               if (i %10 ==0) System.out.println("statements prepared "+ i);
	   }
           int count =0;
	   for (int i=0; i <100 ; i++)
	   {      
               stmt[i].setInt(1, i);
               stmt[i].setString(2, String.valueOf(i+100));
               ret = stmt[i].executeUpdate();
               if (ret != 1) break;
               stmt[i].close();
   	       con.commit();
               count++;
	   }
           System.out.println("Total rows inserted "+ count);
	   cStmt = con.createStatement();
           System.out.println("Listing tuples:");
	   ResultSet rs = cStmt.executeQuery("SELECT * from T1;");
           count=0;
	   while (rs.next())
	   {
	       count++;
	   }
	   rs.close();
	   con.commit();
           cStmt.execute("DROP TABLE T1;");
           con.close();
           if (count == 100) System.exit(0); else System.exit(1);
        }catch(Exception e) {
            System.out.println("Exception in Test: "+e);
            e.printStackTrace();
            System.exit(1);
        }
    }
}

⌨️ 快捷键说明

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