java - Connecto to SQL Server with c# and JDBC -
i have program in java
connect sql server
server = "zf-sql-mtrazdb.nis.local" dbname = "mraz" namebasedatos = "cd_lo" table = "dbo.cd_lo_data" user = "user" password = "pass" url = "jdbc:sqlserver//"+ server + "\\" + dbname + "jdatabasename=" + namebasedatos driver = "com.microsoft.sqlserver.jdbc_sqlserverdriver"
now have same visual c# 2010
in windows xp
how can program?? because in java use jdbc
, should use jdbc
?
thanks all!
the connectionstring similar ole db
connection string, not identical. unlike ole db or ado, connection string returned same user-set connectionstring
, minus security information if persist security info value set false (default). .net framework data provider sql server
not persist or return password in connection string unless set persist security info true.
you can use connectionstring
property connect database. following example illustrates typical connection string.
"persist security info=false;integrated security=true;initial catalog=northwind;server=(local)"
use new sqlconnectionstringbuilder construct valid connection strings @ run time.
private static void opensqlconnection() { string connectionstring = getconnectionstring(); using (sqlconnection connection = new sqlconnection()) { connection.connectionstring = connectionstring; connection.open(); console.writeline("state: {0}", connection.state); console.writeline("connectionstring: {0}", connection.connectionstring); } } static private string getconnectionstring() { // avoid storing connection string in code, // can retrieve configuration file. return "data source=mssql1;initial catalog=adventureworks;" + "integrated security=true;"; }
data source
orserver or
addressor
addror
network address: name or network address of instance of sql server connect. port number can specified after server name :
server=tcp:servername, portnumber`- the
initial catalog
ordatabase
: name of database. database name can 128 characters or less. - the
integrated security
ortrusted_connection
: whenfalse
,user id
,password
specified in connection. when true, current windows account credentials used authentication. recognized values true,false
, yes, no, ,sspi
(strongly recommended), equivalenttrue
. ifuser id
,password
specified , integrated security set true,user id
,password
ignored ,integrated security
used.
and other items
i hope :) .
Comments
Post a Comment