【发布时间】:2014-11-26 14:53:43
【问题描述】:
public void Execute_Select_Statement(String instruction) throws SQLException
{
PreparedStatement ps = null;
try
{
ps = this.conn.prepareStatement(instruction);
ResultSet rs = ps.executeQuery();
while (rs.next())
{
String column = rs.getString(1);
System.out.println("column1:" + column);
}
}
catch(SQLException e)
{
System.out.println(e.getMessage());
}
finally
{
if(ps != null)
{
ps.close();
}
}
}
我现在有了上面的代码,它从 oracle 数据库中的表中获取特定列。但是当我想获得更多列时,我必须添加另一个 getstring。我该如何解决它,它首先获取给定表的列数,然后从中获取信息?
【问题讨论】:
-
你说得对,我是新来的 stackoverflow 问题,抱歉。@Maheswaran Ravisankar
标签: java mysql sql oracle jdbc