码迷,mamicode.com
首页 > 数据库 > 详细

数据库连接语句

时间:2017-07-12 01:22:32      阅读:230      评论:0      收藏:0      [点我收藏+]

标签:sof   home   har   ssl   connect   source   user   manager   cat   

Java连接MySQL

  protected final static String DB_DRIVER = "com.mysql.jdbc.Driver";

  protected final String DB_URL = "jdbc:mysql://localhost:3306/melancholy?characterEncoding=utf8&useSSL=true";

  protected final String DB_USER = "a0109151216";

  protected final String DB_PWD = "44045d6f";

  Class.forName(DB_DRIVER);

  connection = DriverManager.getConnection(DB_URL, DB_USER, DB_PWD);

Java连接SQLserver

  private static final String DB_DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver";

  private static final String DB_URL = "jdbc:sqlserver://localhost:1433;databasename=easybuy";

  private static final String DB_USER = "sa";

  private static final String DB_PWD = "sa";

  Class.forName(DB_DRIVER);

  conn = DriverManager.getConnection(DB_URL,DB_USER,DB_PWD);

C#连接MySQL

  <connectionStrings>

    <add name ="MainConnectionString"

      connectionString="Server=localhost;Database=Melancholy;Uid=root;Pwd=root.;"

      providerName="System.Data.MySqlClient"/>

  </connectionStrings>

C#连接SQLserver

  <connectionStrings>

    <add name ="MyHomeConnectionString"

      connectionString="Data Source=.;Initial Catalog=HotelManageEx;User ID=sa;Password=sa"

      providerName="System.Data.SqlClient"/>

  </connectionStrings>

数据库连接语句

标签:sof   home   har   ssl   connect   source   user   manager   cat   

原文地址:http://www.cnblogs.com/gaofei-1/p/7152966.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!