Here you can find the source of getDataFromTable(String tableName, String[] columns)
public static LinkedList<String> getDataFromTable(String tableName, String[] columns)
//package com.java2s; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.LinkedList; public class Main { public static LinkedList<String> getDataFromTable(String tableName, String[] columns) { Connection conn = getConnection(); LinkedList<String> list = new LinkedList<String>(); try {/*from w w w.j a v a2 s.c o m*/ Statement st = conn.createStatement(); String sb = "select * from " + tableName; ResultSet rs = st.executeQuery(sb); while (rs.next()) { StringBuilder sql = new StringBuilder(); sql.append( "INSERT INTO leo_primitive_type (leo_uuid, leo_database_type, leo_ruby_type,leo_java_type,leo_identifier) VALUES ('"); sql.append(rs.getString("io_uuid")).append("','").append(rs.getString("io_database_type")) .append("','").append(rs.getString("io_ruby_type")).append(rs.getString("io_java_type")) .append("','").append(rs.getString("io_identifier")).append("','").append("');"); list.add(sql.toString()); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return list; } private static Connection getConnection() { Connection con = null; try { Class.forName("org.postgresql.Driver"); String url = " jdbc:postgresql://localhost:5432/intalio"; con = DriverManager.getConnection(url, "postgres", "root"); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return con; } }