显示标签为“连接字符串”的博文。显示所有博文
显示标签为“连接字符串”的博文。显示所有博文

2008年11月21日星期五

.Net连接Active Directory(活动目录)的连接字符串

Provider=ADSDSOObject;User Id=域用户账户;Password=密码;

.Net连接Informix的连接字符串

IBM Informix OLE DB Provider

Provider=Ifxoledbc.2;Password=myPassword;User ID=myUsername;Data Source=数据库名@服务器名;Persist Security Info=true;

.Net连接Excel 2007的连接字符串

Excel 2007
----------
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myExcel2007file.xlsx;Extended Properties="Excel 12.0;HDR=YES";

.Net连接Access 2007的连接字符串

Access 2007
-----------
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccess2007file.accdb;Persist Security Info=False;

Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccess2007file.accdb;Jet OLEDB:Database Password=MyDbPassword;

.Net连接Excel(97~2003)的连接字符串

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyExcel.xls;Extended Properties="Excel 8.0;HDR=Yes;IMEX=1";

.NET连接Access (97~2003)的连接字符串

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;User Id=admin;Password=;

.Net连接IBM DB2的连接字符串

使用OleDbConnection (.NET) from Microsoft
Provider=DB2OLEDB;Network Transport Library=TCPIP;Network Address=XXX.XXX.XXX.XXX;Initial Catalog=数据库;Default Schema=架构;User ID=帐号;Password=密码;

.Net连接MySQL的连接字符串

使用OleDbConnection
Provider=MySQLProv;Data Source=数据库名;User Id=帐号;Password=密码;

.Net连接Oracle的连接字符串

1,OleDbConnection
Provider=msdaora;Data Source=Oracle数据库;User Id=帐号;Password=密码;

Provider=OraOLEDB.Oracle;Data Source=Oracle数据库;User Id=帐号;Password=密码;

Provider=msdaora;Data Source=Oracle数据库;Persist Security Info=False;Integrated Security=Yes;

Provider=OraOLEDB.Oracle;Data Source=Oracle数据库;OSAuthent=1;

2,Oracle Data Provider, ODP.NET
Data Source=Oracle数据库;Integrated Security=yes; Data Source=Oracle数据库;User Id=帐号;Password=密码;

.Net连接SQL Server 2005 的连接字符串

1,SQL标准连接
Data Source=服务器;Initial Catalog=数据库;User Id=帐号;Password=密码;

2,可信连接(Windows连接)
Data Source=服务器;Initial Catalog=数据库;Integrated Security=SSPI;

Data Source=服务器;Initial Catalog=数据库;Trusted_Connection=True;

3,Native Client OLE DB Provider
Provider=SQLNCLI;Data Source=服务器;Initial Catalog=数据库;User Id=帐号;Password=密码;

Provider=SQLNCLI;Data Source=服务器;Initial Catalog=数据库;Integrated Security=SSPI;

Provider=SQLNCLI;Data Source=服务器;Initial Catalog=数据库;Trusted_Connection=True;

.Net连接SQL Server 2000 的连接字符串

1,SQL标准连接
Data Source=服务器;Initial Catalog=数据库;User Id=帐号;Password=密码;

2,可信连接(Windows连接)
Data Source=服务器;Initial Catalog=数据库;Integrated Security=SSPI;

Data Source=服务器;Initial Catalog=数据库;Trusted_Connection=True;

2008年11月13日星期四

JDBC直连用连接字符串速查

各种数据库直连方式速查表

  1、Oracle8/8i/9i数据库(thin模式)

Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@服务器名或IP地址:1521:数据库SID";
String user="用户名";
String password="密码";
Connection conn= DriverManager.getConnection(url,user,password);


  2、DB2数据库

Class.forName("com.ibm.db2.jdbc.app.DB2Driver ").newInstance();
String url="jdbc:db2:// 服务器名或IP地址:5000/数据库名";
String user="帐号";
String password="密码";
Connection conn= DriverManager.getConnection(url,user,password);


  3、Sql Server7.0/2000数据库

Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver:// 服务器名或IP地址:1433;DatabaseName=数据库名";
String user="帐号";
String password="密码";
Connection conn= DriverManager.getConnection(url,user,password);


  4、Sybase数据库

Class.forName("com.sybase.jdbc.SybDriver").newInstance();
String url =" jdbc:sybase:Tds: 服务器名或IP地址:5007/数据库名";/
Properties sysProps = System.getProperties();
SysProps.put("user","帐号");
SysProps.put("password","密码");
Connection conn= DriverManager.getConnection(url, SysProps);


  5、Informix数据库

Class.forName("com.informix.jdbc.IfxDriver").newInstance();
String url = "jdbc:informix-sqli://服务器IP地址:1533/数据库名:INFORMIXSERVER=服务器名; user=帐号;password=密码";
Connection conn= DriverManager.getConnection(url);


  6、MySQL数据库

Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url ="jdbc:mysql:// 服务器名或IP地址/数据库名?user=帐号&password=密码&useUnicode=true&characterEncoding=8859_1"
Connection conn= DriverManager.getConnection(url);


  7、PostgreSQL数据库

Class.forName("org.postgresql.Driver").newInstance();
String url ="jdbc:postgresql:// 服务器名或IP地址/数据库名"
String user="帐号";
String password="密码";
Connection conn= DriverManager.getConnection(url,user,password);


  8、access数据库直连(通过ODBC)

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver") ;
String url="jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=数据库文件名";
Connection conn = DriverManager.getConnection(url,"","");

9、SQL Server2005

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
String url="jdbc:sqlserver:// 服务器名或IP地址:1433;databaseName=数据库名; user=帐号;password=密码"
Connection conn= DriverManager.getConnection(url);

2008年11月6日星期四

SQL Server 2008 连接字符串(SqlConnection)

SQL Server 2008
SqlConnection

标准登录:
Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;

可信连接:
Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;

通过IP地址连接:
Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;

附加数据库文件到本地SQLExpress:
Server=.\SQLExpress;AttachDbFilename=c:\asd\qwe\mydbfile.mdf;Database=dbname; Trusted_Connection=Yes;

附加数据文件夹中的数据库文件到本地SQLExpress:
Server=.\SQLExpress;AttachDbFilename=DataDirectorymydbfile.mdf; Database=dbname;Trusted_Connection=Yes;

SQL Server 2008 连接字符串(SQL Native Client OLE DB Provider)

SQL Server 2008
SQL Native Client OLE DB Provider
标准登录:
Provider=SQLNCLI10;Server=myServerAddress;Database=myDataBase;Uid=myUsername; Pwd=myPassword;

可信连接:
Provider=SQLNCLI10;Server=myServerAddress;Database=myDataBase; Trusted_Connection=yes;

网络传递数据加密:
Provider=SQLNCLI10;Server=myServerAddress;Database=myDataBase; Trusted_Connection=yes;Encrypt=yes;

附加数据库文件到SQLExpress
Provider=SQLNCLI10;Server=.\SQLExpress;AttachDbFilename=c:\asd\qwe\mydbfile.mdf; Database=dbname; Trusted_Connection=Yes;

附加数据文件夹中的数据库文件到本地SQLExpress
Provider=SQLNCLI10;Server=.\SQLExpress;AttachDbFilename=DataDirectorymydbfile.mdf; Database=dbname;Trusted_Connection=Yes;

SQL Server 2008 连接字符串(ODBC)

SQL Server 2008
SQL Native Client ODBC Driver

标准登录:
Driver={SQL Server Native Client 10.0};Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;


可信连接:
Driver={SQL Server Native Client 10.0};Server=myServerAddress;Database=myDataBase;Trusted_Connection=yes;

网络传递数据加密:
Driver={SQL Server Native Client 10.0};Server=myServerAddress;Database=myDataBase; Trusted_Connection=yes;Encrypt=yes;

附加数据库文件到SQLExpress
Driver={SQL Server Native Client 10.0};Server=.\SQLExpress; AttachDbFilename=c:\asd\qwe\mydbfile.mdf; Database=dbname;Trusted_Connection=Yes;

附加数据文件夹中的数据库文件到本地SQLExpress
Driver={SQL Server Native Client 10.0};Server=.\SQLExpress;AttachDbFilename=DataDirectorymydbfile.mdf; Database=dbname;Trusted_Connection=Yes;