- Java code
import java.sql.Connection;import java.sql.ParameterMetaData;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.SQLException;//参数的数据源信息public class PMMD { public static void main(String[] args) throws SQLException { read("select id,name,birthday,money from user1 where name=? and birthday<? and money>?",null); } static void read(String sql,Object[] params) throws SQLException{ Connection conn = null; PreparedStatement ps = null; ResultSet rs = null; try { conn = JdbcUtilsSing.getInstance().getConnection(); ps = conn.prepareStatement(sql); ParameterMetaData pmd = ps.getParameterMetaData(); int count = pmd.getParameterCount(); for(int i =1;i<=count;i++){ System.out.print(pmd.getParameterClassName(i)+"\t"); System.out.print(pmd.getParameterType(i)+"\t"); System.out.println(pmd.getParameterTypeName(i)); } } finally{ JdbcUtils.free(rs,ps,conn); } }}
报错如下:
- Java code
Exception in thread "main" java.sql.SQLException: 不支持的特性 at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:119) at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:115) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:221) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:293) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:574) at oracle.jdbc.driver.DatabaseError.throwUnsupportedFeatureSqlException(DatabaseError.java:1009) at oracle.jdbc.driver.OracleParameterMetaData.getParameterClassName(OracleParameterMetaData.java:193) at com.jdbc.PMMD.read(PMMD.java:27) at com.jdbc.PMMD.main(PMMD.java:12)
这真神奇了,实在不知道什么原因,求高人们解答~~
------解决方案--------------------------------------------------------