Jdbc:
Do?
can be a corresponding relationship between a program and a database
And can operate the database to facilitate the program to obtain data and operational data
How to manipulate the database:
1, establish the connection
2, open the channel
3. Get (manipulate) data
Running the SQL file needs to run in a specified database
The advantage of ToString is that it is called automatically when it encounters an output method such as "println", without explicitly hitting it.
The function of an interface is to implement multiple inheritance because only one class can be inherited
Http://www.cnblogs.com/timlearn/p/4063850.html
The interface should instantiate the corresponding implementation class when it is used
Rs.next (); Gets the information for a column of a table in the database
Rs.getobject (index); Gets the row information for the table of the database
Alt+x Screen Cutting
Ctrl+1 shortcut key, new Student ();
First build a Lib file under the project, add the schema package, then click on the schema package, right click on the build Path to click on the bottle, drive the success, and then run the code
Java Connection database:
1, load Driver
try {
Class.forName ("Com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e) {
TODO auto-generated Catch block
E.printstacktrace ();
}
2, establish the connection
try {
Connection = Drivermanager.getconnection ("Jdbc:mysql://127.0.0.1:3306/class", "root", "1234546");
} catch (SQLException e) {
TODO auto-generated Catch block
E.printstacktrace ();
}
3, open channel (use SQL statement to manipulate database)
statement = Connection.createstatement ();
String sql = "SELECT * from student";
rs = statement.executequery (SQL);
4. Get information
Next is to determine that there is no next piece of information 0
When the result of the judgment has the next message, this time the next bidding clubs from 1
while (Rs.next ()) {
String o = rs.getstring (1);
String O2 = rs.getstring (2);
System.out.print (O + "");
System.out.print (O2);
System.out.println ();
}
5. Close all connections
Regardless of whether the operating database is successful or not, you must close it so that you use finally
finally{
try {
Rs.close ();
Statement.close ();
Connection.close ();
} catch (SQLException e) {
TODO auto-generated Catch block
E.printstacktrace ();
}
}
Statement State channel for simple queries and operations
Pass? To pass information in such a way called preprocessing.
PreparedStatement Pre-Channel
When you frequently use modify to delete a single message
JDBC Operations Database