jdbc获得所有数据库表

	public static void displayTable()throws Exception{
		java.sql.ResultSet rs=null;
		java.sql.Connection con=null;
		java.sql.PreparedStatement ps= null;
		try{
			con=org.apache.commons.dbutils.DbUtils.getDataSource().getConnection();
			java.sql.DatabaseMetaData dm=con.getMetaData();
			rs=dm.getTables(null, "%", "%", new String[]{"table"});
			while(rs.next()){
				System.out.println(rs.getString("table_name"));
			}
		}finally{
			org.apache.commons.dbutils.DbUtils.closeQuietly(con);
		}
		
	}

 

你可能感兴趣的:(jdbc)