📄 mysqlunit.java
字号:
/* * MySqlUnit.java * * Created on 2001年5月18日, 上午10:49 */package zc.face;import java.io.*;import java.sql.*;/** * * @author Administrator * @version */class MySqlUnit { /** Creates new MySqlUnit */ public static String printMetaData(ResultSet rs) throws SQLException { ResultSetMetaData md=rs.getMetaData(); int colCount=md.getColumnCount(); String colLabel[]=new String[colCount+1]; int colDisplaySize[]=new int[colCount+1]; String colTypeName[]=new String[colCount+1]; System.out.println("database colCount="+colCount); StringBuffer sb=new StringBuffer(); for(int i=1;i<=colCount;i++){ colLabel[i]=md.getColumnLabel(i); colDisplaySize[i]=md.getColumnDisplaySize(i); colTypeName[i]=md.getColumnTypeName(i); sb.append("Label:"+colLabel[i]+"DisplaySize:"+colDisplaySize[i]+"TypeName:"+colTypeName[i]+"\r\n"); } return sb.toString(); } public static String printResultSet(ResultSet rs) throws IOException,SQLException { ResultSetMetaData md=rs.getMetaData(); int colCount=md.getColumnCount(); String colLabel[]=new String[colCount+1]; for(int i=1;i<=colCount;i++) colLabel[i]=md.getColumnLabel(i); StringBuffer sb=new StringBuffer(); while(rs.next()){ for(int i=1;i<=colCount;i++) sb.append(colLabel[i]+":"+rs.getObject(i)+" "); sb.append("\r\n"); } //if(!rs.next( )) // System.out.println("查询成功"); // else // System.out.println("查询失败"); return sb.toString( ); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -