兼容oracle字段大写
最近更新时间: 2024-10-17 17:10:00
import java.sql.*;
public class oracle_test {
public static void main(String args[]) {
Connection c = null;
Statement stmt = null;
try {
Class.forName("org.postgresql.Driver");
c = DriverManager.getConnection("jdbc:postgresql://172.16.0.30:11345/postgres?oracle_compile=true","tbase", "tbase");
c.setAutoCommit(false);
System.out.println("Opened database successfully");
PreparedStatement preparedStatement = null;
try {
preparedStatement = c.prepareStatement("select * from public.select_normal");
ResultSetMetaData metaData = preparedStatement.getMetaData();
for (int i = 0; i < metaData.getColumnCount(); i++) {
// resultSet数据下标从1开始
String columnName = metaData.getColumnName(i + 1);
int type = metaData.getColumnType(i + 1);
System.out.println("列名:"+columnName);
}
} catch (SQLException e) {
e.printStackTrace();
}
} catch (Exception e) {
System.err.println( e.getClass().getName()+": "+ e.getMessage() );
System.exit(0);
}
System.out.println("Records created successfully");
}
}