Database connection Tool class database connection tool class--just get the connection object Conndb.java

Source: Internet
Author: User

  1. Package com.util;
  2. Import java.sql.Connection;
  3. Import Java.sql.DriverManager;
  4. /**
  5. * Database Connection Tool Class--just get the connection object
  6. *
  7. */
  8. Public class Conndb {
  9. private static Connection conn = null;
  10. private static final String driver_name = "Com.mysql.jdbc.Driver";
  11. private static final String URL = "jdbc:mysql://localhost:3306/axt?useunicode=true&  Characterencoding=utf-8 ";
  12. private Static final String user_name = "root";
  13. private static final String PASSWORD = "root";
  14. public static Connection Getconn () {
  15. try {
  16. Class.forName (driver_name);
  17. conn = Drivermanager.getconnection (URL, user_name, PASSWORD);
  18. } catch (Exception e) {
  19. E.printstacktrace ();
  20. }
  21. return conn;
  22. }
  23. }

Database Connection Tool class database connection tool class--just get the connection object Conndb.java

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.