Current location - Training Enrollment Network - Books and materials - How to write the code for searching books with myeclipse? What is the train of thought? Ask the master for advice. Thank you!
How to write the code for searching books with myeclipse? What is the train of thought? Ask the master for advice. Thank you!
First, create an oracle database demo and subscribe to the form.

//Connect to the database using java.

Connection Connection = empty;

Stat = null statement;

Try {

class . forname(" Oracle . JDBC . driver . Oracle driver "); //If it is db2, it is class.forname ("com.ibm.db2.jdbc.app.db2driver"). new instance();

Conn = drivermanager.getconnection ("JDBC: Oracle: thin: @ dbserver:1521:demo", "user name" and "password");

string sqlString = " select * from Books "; //retrieve the SQL of the book

stat = conn . create statement();

return stat . execute(SQL string);

}catch (exception e){

//Exception handling

} Finally {

if(null! = connected) {

conn . close();

}

if(null! = stat ){

stat . close();

}

}