JDBC use

xiaoxiao2021-03-06  67

Simply put, JDBC can do three things:

1. Establish a connection with the database

2. Send SQL statements

3. Processing results.

The following code segments give the above three steps:

// Establish a database connection

Connection Con = DriverManager.getConnection ("JDBC: ODBC: Wombat", "Login", "Password");

// Create a Statement object

Statement Stmt = con.createstatement ();

/ / Execute the SQL statement and return the result

ResultSet RS = Stmt.executeQuery ("SELECT A, B, C from Table");

While (rs.next ()) {

INT x = rs.Getint ("a");

String s = rs.getstring ("b");

Float f = rs.getfloat ("c");

}

转载请注明原文地址:https://www.9cbs.com/read-120644.html

New Post(0)