Java connection mysql and SQL server2008 code

Source: Internet
Author: User

These two days connect MySQL and SQL server2008 code separately in Java. It was all wrong at the beginning. Now find the code that successfully connects on your machine:

1. mysql

Class.forName ("Com.mysql.jdbc.Driver"). newinstance ();

String url= "jdbc:mysql://localhost:3306/website? Characterencoding=utf8";//website is the database name. Read Chinese characters in MySQL

String user= "root";//Login to MySQL username and password

String pwd= "123456";

Con=drivermanager.getconnection (URL,USER,PWD);


2. SQL server2008
Class.forName ("com.microsoft.sqlserver.jdbc.SQLServerDriver"). newinstance ();

String url= "jdbc:sqlserver://localhost:1433;databasename=website";

String user= "SA"; //Login to SQL Server username and password

String pwd= "123456";

Con=drivermanager.getconnection (URL,USER,PWD);


Java connection mysql and SQL server2008 code

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.