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