数据库连接语句

Posted 南橘

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了数据库连接语句相关的知识,希望对你有一定的参考价值。

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>

以上是关于数据库连接语句的主要内容,如果未能解决你的问题,请参考以下文章

SQL语句中两个表的连接

SQL语句中两个表的连接

用sql语句进行多表连接查询,怎么不查出重复数据

怎样用SQL语句断开数据库的连接?

6.2SQL基础----2 DML语句数据操纵语句----连接操作

连接两表查询结果的SQL语句