Here is a simple sequence for ADO.NET:
// 1. create a connection
SqlConnection conn = new SqlConnection (xyz)
// 2. open the connection
conn.Open ();
// 3. create a command
SqlCommand cmd = new SqlCommand ("select * from xyz", conn);
// 4. execute and receive the result in a reader
SqlDataReader rdr = cmd.ExecuteReader ();
// 5. get the results
while (rdr.Read ())
{
// dosomething
}
Here is a simple sequence for JDBC:
// 1. create a connection
Connection con = DriverManager.getConnection (xyz);
// 2. create a statement
Statement stmt = con.createStatement ();
// 3. execute and receive results in a result set
ResultSet rs = stmt.executeQuery ("SELECT * from xyz");
// 4. Get the results
while (rs.next ())
{
// do something
}
And here is the analogy (ADO.NET => JDBC):
SqlConnection => Connection
SqlCommand => Statement
SqlDataReader => ResultSet
Amr H. Abd Elmajeed
source share