Program development Sometimes there are a number of special database tables, this time a binding T data column is more troublesome, you can query the database column name, directly output, you can output columns, add different content output
/*** This method separates the table names according to the result set of the query, so they are displayed sequentially *@paramtableName database table name *@authorTXF*/ Public voidgetAllUsers (String tableName) {Connection conn=Dbconnection.getconn (); String SQL= "SELECT * from" +tablename+ "where Rownum=1"; PreparedStatement stmt=NULL; ResultSet RS=NULL; String name=""; Try{stmt=conn.preparestatement (SQL); RS=Stmt.executequery (); ResultSetMetaData RSMD=Rs.getmetadata (); for(intI=1;i<=rsmd.getcolumncount (); i++) {Name=Rsmd.getcolumnname (i); //if (S.get ("Memo") ==null) pstmt.setstring (13, ""); Else Pstmt.setstring (S.get ("Memo"). toString ());System.out.println ("if (S.get (\" "+name.tolowercase () +" \ ") ==null) pstmt.setstring (" +i+ ", \" \ "); else pstmt.setstring ("+i+", S.get (\ "" "+name.tolowercase () +" \ "). toString ());"); //System.out.print (name+ ","); //System.out.print ("?,"); } } Catch(SQLException e) {e.printstacktrace (); } finally{dbconnection.close (RS,NULL, STMT, conn); } }
Java Query database column name, output code that needs to be written