Connect to the SQList database using JAVA.

Source: Internet
Author: User

A file-based database is a very special database. Because they do not have network interfaces, they generally cannot be called in a distributed manner. However, they have great advantages. If they are used for data configuration and data caching, the software efficiency can be improved.
I prefer SQList for such a variety of file databases,
1. It is a stable database;
2. Reduce data type conversion during development regardless of the data type;
3. It is more stable than other text data such as access;
 
Sqlitejdbc-v056.jar: www.sqlite.org download
 
The following is the source code of some JAVA operations on SQList:
 
Java code
Public String [] [] localHostQuery (String SQL ){
String re [] [] = null;
Try {
Class. forName ("org. sqlite. JDBC ");
Connection conn = DriverManager. getConnection ("jdbc: sqlite: buffer. db ");
Statement stat = conn. createStatement ();
ResultSet rs = stat.exe cuteQuery (SQL); // query data
ResultSetMetaData md = rs. getMetaData ();
Re = new String [500] [md. getColumnCount ()];
Int I = 0;
Try {
While (rs. next ()){
For (int j = 0; j <md. getColumnCount (); j ++ ){
Re [I] [j] = rs. getString (j + 1 );
}
I ++;
}
} Catch (Exception e ){
E. printStackTrace ();
}
Rs. close ();
Conn. close (); // end the database connection
 
} Catch (Exception e ){
E. printStackTrace ();
}
Return re;
}
 
Public int localHostUpdate (String SQL ){
Int I = 0;
Try {
Class. forName ("org. sqlite. JDBC ");
Connection conn = DriverManager. getConnection ("jdbc: sqlite: buffer. db ");
Statement stat = conn. createStatement ();
I = stat.exe cuteUpdate (SQL );
Conn. close ();
} Catch (Exception e ){
E. printStackTrace ();
}
Return I;
}

The author "don't look at how fast it is, but how far it is ."

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.