|
|
@@ -26,7 +26,11 @@ public class ImplementSqlService {
|
|
|
执行数据源
|
|
|
*/
|
|
|
public RepEntity implementSql(ToSql toSql) {
|
|
|
-// List<String> checkSql = java.util.Arrays.asList(toSql.getStrSql().split(" "));
|
|
|
+ List<String> checkSql = java.util.Arrays.asList(toSql.getStrSql().toLowerCase().split(" "));
|
|
|
+ if (checkSql.contains("update") || checkSql.contains("delete") || checkSql.contains("insert") ||
|
|
|
+ checkSql.contains("drop") || checkSql.contains("create") || checkSql.contains("comment")){
|
|
|
+ return new RepEntity(RepCode.SqlWarn);
|
|
|
+ }
|
|
|
String sqlStr = "select * from (" + toSql.getStrSql() + ") where rownum <=1";
|
|
|
System.out.println(sqlStr);
|
|
|
if ("".equals(sqlStr) || sqlStr == null) {
|
|
|
@@ -54,49 +58,49 @@ public class ImplementSqlService {
|
|
|
/*
|
|
|
执行数据源test
|
|
|
*/
|
|
|
- public RepEntity getColumnTest(ToSql toSql){
|
|
|
- String sqlStr = toSql.getStrSql();
|
|
|
- Connection conn = null;
|
|
|
- try {
|
|
|
- String url = "jdbc:oracle:thin:@218.17.158.219:1521/orcl";
|
|
|
- String user = "UAS";
|
|
|
- String pass = "select!#%*(";
|
|
|
- conn = DriverManager.getConnection(url,user,pass);
|
|
|
- String sql="select as_id from accidinsur";
|
|
|
- PreparedStatement stmt;
|
|
|
- stmt = conn.prepareStatement(sql);
|
|
|
- System.out.println("...........");
|
|
|
- ResultSet rs = stmt.executeQuery(sql);
|
|
|
- System.out.println("1111111111");
|
|
|
-
|
|
|
- ResultSetMetaData rsmd = rs.getMetaData();
|
|
|
- String name = rsmd.getCatalogName(1);
|
|
|
- int col = rsmd.getColumnCount(); //获得列的个数
|
|
|
- System.out.println("num"+col);
|
|
|
- System.out.println("name"+name);
|
|
|
-
|
|
|
- ResultSetMetaData data = rs.getMetaData();
|
|
|
- while (rs.next()) {
|
|
|
- for (int i = 1; i <= data.getColumnCount(); i++) {
|
|
|
- //获得所有列的数目及实际列数
|
|
|
- int columnCount = data.getColumnCount();
|
|
|
- System.out.println("数:"+columnCount);
|
|
|
- // 获得指定列的列名
|
|
|
- String columnName = data.getColumnName(i);
|
|
|
- System.out.println("ming:"+columnName);
|
|
|
- //获得指定列的列值
|
|
|
- String columnValue = rs.getString(i);
|
|
|
- System.out.println("value"+columnValue);
|
|
|
- //获得指定列的数据类型
|
|
|
- int columnType = data.getColumnType(i);
|
|
|
- System.out.println("type"+columnType);
|
|
|
- }
|
|
|
- }
|
|
|
- }catch (SQLException e){
|
|
|
-
|
|
|
- }
|
|
|
- return new RepEntity(RepCode.success);
|
|
|
- }
|
|
|
+// public RepEntity getColumnTest(ToSql toSql){
|
|
|
+// String sqlStr = toSql.getStrSql();
|
|
|
+// Connection conn = null;
|
|
|
+// try {
|
|
|
+// String url = "jdbc:oracle:thin:@218.17.158.219:1521/orcl";
|
|
|
+// String user = "UAS";
|
|
|
+// String pass = "select!#%*(";
|
|
|
+// conn = DriverManager.getConnection(url,user,pass);
|
|
|
+// String sql="select as_id from accidinsur";
|
|
|
+// PreparedStatement stmt;
|
|
|
+// stmt = conn.prepareStatement(sql);
|
|
|
+// System.out.println("...........");
|
|
|
+// ResultSet rs = stmt.executeQuery(sql);
|
|
|
+// System.out.println("1111111111");
|
|
|
+//
|
|
|
+// ResultSetMetaData rsmd = rs.getMetaData();
|
|
|
+// String name = rsmd.getCatalogName(1);
|
|
|
+// int col = rsmd.getColumnCount(); //获得列的个数
|
|
|
+// System.out.println("num"+col);
|
|
|
+// System.out.println("name"+name);
|
|
|
+//
|
|
|
+// ResultSetMetaData data = rs.getMetaData();
|
|
|
+// while (rs.next()) {
|
|
|
+// for (int i = 1; i <= data.getColumnCount(); i++) {
|
|
|
+// //获得所有列的数目及实际列数
|
|
|
+// int columnCount = data.getColumnCount();
|
|
|
+// System.out.println("数:"+columnCount);
|
|
|
+// // 获得指定列的列名
|
|
|
+// String columnName = data.getColumnName(i);
|
|
|
+// System.out.println("ming:"+columnName);
|
|
|
+// //获得指定列的列值
|
|
|
+// String columnValue = rs.getString(i);
|
|
|
+// System.out.println("value"+columnValue);
|
|
|
+// //获得指定列的数据类型
|
|
|
+// int columnType = data.getColumnType(i);
|
|
|
+// System.out.println("type"+columnType);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }catch (SQLException e){
|
|
|
+//
|
|
|
+// }
|
|
|
+// return new RepEntity(RepCode.success);
|
|
|
+// }
|
|
|
|
|
|
/*
|
|
|
判断列类型
|