这是代码: -
public static void main(String[] args) throws SQLException, ClassNotFoundException
{
Class.forName("oracle.jdbc.OracleDriver");
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","hr","root");
PreparedStatement ps = conn.prepareStatement("select * from mails");
ResultSet rs = ps.executeQuery();
System.out.println(rs.next());
}
我有一个名为mails的表,它包含数据。但是当我运行上面的代码时得到的输出是错误的。
我尝试使用数据库中的其他表。我得到的输出为每个表的真实,但对于邮件表
下表: -
mid uname fromid subject sentdate content
------+-----------+----------------+----------------+---------------+-----------
1 to_srivatsav abc@gmail.com Mail1 Subject 10-JAN-17 Test Mail1
2 to_srivatsav xyz@gmail.com Mail2 Subject 12-JAN-17 Test Mail2
3 to_srivatsav cg@gmail.com Mail3 Subject 13-JAN-17 Test Mail2
4 to_srivatsav abcd@gmail.com Mail4 Subject 14-JAN-17 Test Mail2
帮帮我......! 谢谢!