Java SQL Date Format formatSQLForColumnName(Connection conn, String strSQL)

Here you can find the source of formatSQLForColumnName(Connection conn, String strSQL)

Description

format SQL For Column Name

License

Open Source License

Declaration

public static String formatSQLForColumnName(Connection conn,
            String strSQL) throws SQLException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.sql.*;

public class Main {
    private static String myclass = "CommonDB";

    public static String formatSQLForColumnName(Connection conn,
            String strSQL) throws SQLException {
        String method = "formatSQLForColumnName";
        int location = 1000;

        try {/*from  ww w .  ja v  a 2  s .c  o  m*/
            location = 2000;
            Statement stmt = conn.createStatement();

            location = 2100;
            ResultSet rs = stmt.executeQuery(strSQL);

            location = 2200;
            String columnSQL = "";

            location = 2300;
            while (rs.next()) {

                location = 3000;
                //Create the list of columns for a SQL statement below
                if (columnSQL == "") {
                    columnSQL = rs.getString(1);
                } else {
                    columnSQL = columnSQL + ", " + rs.getString(1);
                }
            }

            location = 3500;
            return columnSQL;
        } catch (SQLException ex) {
            throw new SQLException("(" + myclass + ":" + method + ":"
                    + location + ":" + ex.getMessage() + ")");
        }
    }
}

Related

  1. formatFloat(int floatValue)
  2. formatLogParam(Array obj)
  3. formatNumberWithZeroPrefix(int numOfZero, Integer value)
  4. formatSQLError(SQLException e)
  5. formatSqlException( StringBuilder errorMessage, SQLException exception)