Lines 51-56
Link Here
|
51 |
import java.util.Iterator; |
51 |
import java.util.Iterator; |
52 |
import java.util.StringTokenizer; |
52 |
import java.util.StringTokenizer; |
53 |
|
53 |
|
|
|
54 |
import javax.swing.JOptionPane; |
55 |
|
54 |
|
56 |
|
55 |
/** |
57 |
/** |
56 |
* Extracts database metadata information (table names and constraints, their |
58 |
* Extracts database metadata information (table names and constraints, their |
Lines 708-714
Link Here
|
708 |
if (tok.hasMoreElements()) { |
710 |
if (tok.hasMoreElements()) { |
709 |
String firstTok = (String) tok.nextElement(); |
711 |
String firstTok = (String) tok.nextElement(); |
710 |
if(firstTok.equalsIgnoreCase("select")){ |
712 |
if(firstTok.equalsIgnoreCase("select")){ |
711 |
cols = getPrepStmtResultSetColumns(pstmt); |
713 |
cols = getPrepStmtResultSetColumns(pstmt, sqlText); |
712 |
} |
714 |
} |
713 |
} else { |
715 |
} else { |
714 |
cols=null; |
716 |
cols=null; |
Lines 1162-1167
Link Here
|
1162 |
|
1164 |
|
1163 |
/////////////////////////////////////////////////// |
1165 |
/////////////////////////////////////////////////// |
1164 |
} catch (Exception e) { |
1166 |
} catch (Exception e) { |
|
|
1167 |
System.out.println("Error for sql : "+this.sqlText); |
1165 |
e.printStackTrace(); |
1168 |
e.printStackTrace(); |
1166 |
checkProcMetaData = true; |
1169 |
checkProcMetaData = true; |
1167 |
//throw e; |
1170 |
//throw e; |
Lines 1740-1749
Link Here
|
1740 |
String errMsg = ""; |
1745 |
String errMsg = ""; |
1741 |
errPrepStmtParameters = false; |
1746 |
errPrepStmtParameters = false; |
1742 |
Parameter[] parameters = null; |
1747 |
Parameter[] parameters = null; |
|
|
1748 |
ParameterMetaData pmeta = null; |
1743 |
|
1749 |
|
1744 |
try { |
1750 |
try { |
1745 |
|
1751 |
if (pmeta==null) |
1746 |
ParameterMetaData pmeta = pstmt.getParameterMetaData(); |
1752 |
pmeta = pstmt.getParameterMetaData(); |
1747 |
if (pmeta != null) { |
1753 |
if (pmeta != null) { |
1748 |
int numParams = pmeta.getParameterCount(); |
1754 |
int numParams = pmeta.getParameterCount(); |
1749 |
if (numParams > 0) { |
1755 |
if (numParams > 0) { |
Lines 1850-1861
Link Here
|
1850 |
return parameters; |
1856 |
return parameters; |
1851 |
} |
1857 |
} |
1852 |
|
1858 |
|
1853 |
private ResultSetColumn[] getPrepStmtResultSetColumns(PreparedStatement pstmt) throws SQLException{ |
1859 |
private ResultSetColumn[] getPrepStmtResultSetColumns(PreparedStatement pstmt, String sqlText) throws SQLException{ |
1854 |
String errMsg = ""; |
1860 |
String errMsg = ""; |
1855 |
errPrepStmtResultSetColumns = false; |
1861 |
errPrepStmtResultSetColumns = false; |
1856 |
ResultSetColumn[] cols = null; |
1862 |
ResultSetColumn[] cols = null; |
|
|
1863 |
ResultSetMetaData rsmd = null; |
1857 |
try { |
1864 |
try { |
1858 |
ResultSetMetaData rsmd = pstmt.getMetaData(); |
1865 |
rsmd = pstmt.getMetaData(); |
|
|
1866 |
} |
1867 |
catch (Exception e) { |
1868 |
if (e.getStackTrace()[0].getClassName().contains("oracle.jdbc.driver")) { |
1869 |
try { |
1870 |
int i=0; |
1871 |
try { |
1872 |
while(true) |
1873 |
pstmt.setNull(++i, java.sql.Types.NULL); |
1874 |
} |
1875 |
catch (SQLException sqe) { |
1876 |
// usually no more parameters to bind |
1877 |
} |
1878 |
int res = JOptionPane.showConfirmDialog(null, |
1879 |
"You are using Oracle driver.\r\n"+ |
1880 |
"In order to retrieve SQL statement metadata the statement must be executed.\r\n"+ |
1881 |
"The statement is '" + sqlText + "'.\r\n\r\n"+ |
1882 |
"Do you want to execute this statement?", |
1883 |
"Warning", |
1884 |
JOptionPane.OK_CANCEL_OPTION | JOptionPane.WARNING_MESSAGE |
1885 |
); |
1886 |
if (res==JOptionPane.CANCEL_OPTION) |
1887 |
throw new SQLException("Aborted execution of prepared statement"); |
1888 |
pstmt.execute(); |
1889 |
} |
1890 |
catch (Exception ex) {} |
1891 |
} |
1892 |
} |
1893 |
|
1894 |
try { |
1895 |
if (rsmd==null) |
1896 |
rsmd = pstmt.getMetaData(); |
1859 |
int count = 0; |
1897 |
int count = 0; |
1860 |
if (rsmd != null) { |
1898 |
if (rsmd != null) { |
1861 |
count = rsmd.getColumnCount(); |
1899 |
count = rsmd.getColumnCount(); |
Lines 1870-1878
Link Here
|
1870 |
currCol.setName(rsmd.getColumnName(i)); |
1908 |
currCol.setName(rsmd.getColumnName(i)); |
1871 |
currCol.setSqlType(getSQLTypeDescription(rsmd.getColumnType(i))); |
1909 |
currCol.setSqlType(getSQLTypeDescription(rsmd.getColumnType(i))); |
1872 |
currCol.setJavaType(getJavaFromSQLTypeDescription(currCol.getSqlType())); |
1910 |
currCol.setJavaType(getJavaFromSQLTypeDescription(currCol.getSqlType())); |
1873 |
currCol.setOrdinalPosition(i); |
1911 |
try { |
1874 |
currCol.setNumericPrecision(rsmd.getPrecision(i)); |
1912 |
currCol.setOrdinalPosition(i); |
1875 |
currCol.setNumericScale(rsmd.getScale(i)); |
1913 |
} |
|
|
1914 |
catch (Exception e1) { /*probably not supported*/ } |
1915 |
try { |
1916 |
currCol.setNumericPrecision(rsmd.getPrecision(i)); |
1917 |
} |
1918 |
catch (Exception e2) { /*probably not supported*/ } |
1919 |
try { |
1920 |
currCol.setNumericScale(rsmd.getScale(i)); |
1921 |
} |
1922 |
catch (Exception e3) { /*probably not supported*/ } |
1876 |
|
1923 |
|
1877 |
if (rsmd.isNullable(i) == DatabaseMetaData.columnNullable) { |
1924 |
if (rsmd.isNullable(i) == DatabaseMetaData.columnNullable) { |
1878 |
currCol.setIsNullable(true); |
1925 |
currCol.setIsNullable(true); |