Java Program Access encrypted Access database __c#

Source: Internet
Author: User
Tags odbc stmt access database

I only give a way to access the database:

private void Login () {
String url = "Jdbc:odbc:driver={microsoft Access driver (*.mdb)};D Bq=pdadb.mdb; Pwd=123 ";
Note that there is a space after driver
Try
{
Class.forName ("Sun.jdbc.odbc.JdbcOdbcDriver");
}
catch (ClassNotFoundException ex)
{
Ex.printstacktrace ();
}
Try
{
Connection con = drivermanager.getconnection (URL);
Statement stmt = Con.createstatement ();
String userpasswd = new String (Pwdpf.getpassword ());
ResultSet rs = stmt.executequery ("SELECT * from password where pwd = '" +userpasswd+ "");
if (!rs.next ())
{
Joptionpane.showmessagedialog (null, "wrong password.") ");
} else
{

Joptionpane.showmessagedialog (NULL, "login succeeded.) ");
}
}
catch (SQLException ex)
{
Ex.printstacktrace ();
}
}

Be sure to note that the string url = "Jdbc:odbc:driver={microsoft Access driver (*.mdb)};D Bq=pdadb.mdb; Pwd=123 "; There is a space after the driver in.

Related Article

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.