咱們不妨寫一段這樣的代碼java
import java.sql.*; public class JDBCTest { public static void main(String[] args) throws ClassNotFoundException, SQLException { Class.forName("org.gjt.mm.mysql.Driver"); Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "1234"); String sql="select * from emp e"; PreparedStatement ps = connection.prepareStatement(sql); ResultSet rs = ps.executeQuery(); while (rs.next()){ int id = rs.getInt(1); String name = rs.getString(2); System.out.println(id+"="+name); } rs.close(); ps.close(); connection.close(); } }
這裏咱們知道是從rs這個對象中獲取數據的,大概能猜出是在next時獲取數據的,咱們不妨點進去mysql
進入com.mysql.jdbc.ResultSetImpl#next 方法sql
有這麼一段代碼this.thisRow = this.rowData.next(); 點進去c#
進入com.mysql.jdbc.RowDataStatic#next 查看其屬性,發現有個rows的屬性保存了查詢出的數據且這些數據都是byte類型this