You do not need to configure the access file for connecting to access through Java.

Source: Internet
Author: User

You must use access to create an Access database in advance. (There may be other methods, but this is just my first understanding)

However, it seems that we still use the copy method.

 

However, I don't pay attention to how to create an Access database here, because I just want to implement it. I can use a Java software with an MDB file to go everywhere.

Previously, I always thought that access should be configured and what should be installed, but it seems that access should be free of configuration. This requires further research.

 

I tried to use hsql before and found that it is very tasteless. It is only suitable for testing for temporary use or long-term shutdown.Program. For a small desktop program like me, it is too slow to re-build the entire database every time it is started. Initialization takes over 10 seconds. Then the query speed is slow ~~

 

I tried Java to connect to access, which is very efficient.

  String URL  =     " JDBC: ODBC: Driver = {Microsoft Access Driver (*. mdb)}; DBQ = mydzsw. MDB  "  ;
Try {
// Note: there is a space between driver and (*. mdb ).
Connection con = Drivermanager. getconnection (URL );
Statement sta
= Con. createstatement ();
For ( Int I = 0 ; I < 100000 ; I ++ ){ // 1 minute 10 seconds
Sta.exe cute ( " Insert into persons values ( " + I + " , 'Note', '000000', '000000', '000000 ') " );
}

Resultset set
= Sta.exe cutequery ( " Select * from persons where id_p = 63145 " ); // Millisecond level
Set. Next ();
System. Out. println (set. getstring (
1 ));

Sta. Close ();
Con. Close ();
}
Catch (Sqlexception ex ){
Logger. getlogger (newclass.
Class . Getname (). Log (level. Severe, Null , Ex );
}

 

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.