Java SQL Table getTableName(String sql)

Here you can find the source of getTableName(String sql)

Description

get Table Name

License

Apache License

Declaration

public static String getTableName(String sql) throws SQLException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.sql.SQLException;

public class Main {
    private static final String FROM_KEY = " from ";

    public static String getTableName(String sql) throws SQLException {
        String tableName = "";
        int pos = sql.indexOf(FROM_KEY);
        if (pos >= 0) {
            String tab = sql.substring(pos + FROM_KEY.length(), sql.length());
            int pp = tab.indexOf(' ');
            if (pp >= 0) {
                tableName = tab.substring(0, pp);
            } else {
                tableName = tab;//from  w  w  w  . ja  v a  2  s . c om
            }
        }
        return tableName;
    }
}

Related

  1. getRowCount(Statement stmt, String tableName)
  2. getSensorsList( final Connection jdbcConnection, String tableName)
  3. getShapeText(Connection conn, String tableName)
  4. getTableFields(Connection con, String tableName)
  5. getTableList(Connection connection)
  6. getTableNames(Connection conn)
  7. getTableNames(Connection conn)
  8. getTables(Connection conn)
  9. getTables(Connection connection)