12th Day How can I persist

Source: Internet
Author: User

Today's work, see the use of SEAJS framework, Baidu is Ali before the front-end engineer Yuber wrote, is very admire Ah, but has not carefully studied the principle, JS and jquery are not proficient in it. Take the work seriously, today hit the soy sauce for a day. Review the database connection JDBC Connection:

String jdbcdriver;//defines the database interface class: MySQL is Com.mysql.jdbc.Driver, depending on the database category. )

String URL; Defines the path to access the database; The local MySQL path and port number are: http://localhost:3306/database name

String username;//defines the user name of the database

String password;//defines the access password for the database

The Connection Conn;//connection interface is equivalent to creating a Connection object.

What is PreparedStatement ps;//for? Ready to connect?

Result rs;//Database Results set

Class.forName (jdbcdriver); Load database connection class

Conn=drivermanager.getconnection (Url,username,password);//Create Connection object;

Ps=conn.preparestatement (SQL);//

Rs=ps.executequery ();

while (Rs.next ()) {

String s=rs.getstring (1);//output first column;

String s1=rs.getstring ("column name");

}

Outputs the first few rows of the column

String getDate (int i,int j) {

int k=0;

while (Rs.next ()) {

k++;

if (k==j) {

System.out.println (Rs.getstring (j));

}

}

}

Close (); Defines a method to close the interface: first close the RS, then close PS, and then close the conn;

Database Connection pool:

Since the creation of the connection object consumes more serious resources, the pre-created connection is saved in the collection and is taken directly at the time of use.

Too late, do not write, the brain already has a prototype, now has a lot of mature database connection pool, or in the project to study well.

Tomorrow there will be time to start the blog system that project, while doing learning, but also to learn the next Android, on-line words must be from the mobile end first online. Sleep, goodnight.

12th Day How can I persist

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.