使用JDBC创建数据库对象2
http://www.rdxx.com 01年11月16日 11:07 互联网 我要投稿
返回一个列的数据 results = null; try { results = new resultSet(dma.getColumns(catalog, null, tablename, null)); } catch (Exception e) {System.out.println(e.getMessage());} return results.getMetaData(); } //-- public String[] getColumnNames(String table) { //返回一个列名数组 String[] tbnames = null; Vector tname = new Vector(); try { results = new resultSet(dma.getColumns(catalog, null, table, null)); while (results.hasMoreElements() ) tname.addElement(results.getColumnValue("COLUMN_NAME")); } catch (Exception e) {System.out.println(e);} tbnames = new String[tname.size()]; for (int i=0; i< tname.size(); i++) tbnames[i] = (String)tname.elementAt(i); return tbnames; } //--public String getColumnValue(String table, String columnName) { //返回给定列的值 String res = null; try { if (table.length()>0) results = Execute("Select " + columnName + " from " + table + " order by "+columnName); if (results.hasMoreElements()) res = results.getColumnValue(columnName); } catch (Exception e) {System.out.println("Column value error" + columnName+ e.getMessage());} return res; }//-- public String getNextValue(String columnName) { // 上一页 下一页
