Heim  >  Artikel  >  Datenbank  >  Mysql的最大连接数怎样用java程序测试_MySQL

Mysql的最大连接数怎样用java程序测试_MySQL

WBOY
WBOYOriginal
2016-06-01 14:04:35819Durchsuche
 

以前工作的时候由于Oracle8i数据库经常出现用户过多的错误,由于数据量大,经常出现ORA:12500错误,但主要原因是访问过多而引起的,后来就用Java写了个简单的用JDBC连接来测试Oracle最大连接数的程序.现在常用MySQL,所以又写了一个简单的测试其最大连接数的程序,在此介绍给大家:

 

<ccid_code></ccid_code>import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.Statement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.io.IOException;
 
 class testMaxConn{
   public static void main(String args[]){
     int count=0;
     Connection []conn=new Connection[1000];
     Statement  []stmt =new Statement[1000];
     ResultSet  []rs =new ResultSet[1000];
    try{
     Class.forName
("com.MySQL.jdbc.Driver").newInstance();
for(count=0;count=0;count--){
         rs[count].close();
         stmt[count].close();
         conn[count].close();
         System.out.print(count+"\t");
        }
      }catch(SQLException ex){
       System.out.println
("\n Close connection exception:"+ex.toString());
      }catch(IOException io_ex){}
    }//end the first "try"
   }
 }
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn