Setup SQL Server for Connecting with Java -
i'm writing java program connects sql server 2012 database. have got working, took experimenting. had was:
- enable tcp/ip
- start "sql server browser" service
is there way perform these 2 actions using sql commands, instead of use having manually? reason don't want user have it, because adds complications.
thanks!
yes of course (for enabling tcp)
--step 1: creating login (mandatory) create login login_to_system_after_injection password='thank$sql4registry@ccess'; go --step 2: enabling both windows/sql authentication mode /*some server specific configurations not stored in system (sql)*/ --set value 1 disabling sql authentication mode after . . . exec xp_regwrite n'hkey_local_machine', n'software\microsoft\mssqlserver\mssqlserver', n'loginmode', reg_dword, 2; --step 3:getting server instance name declare @spath nvarchar(256); --sql server v100 path, use sql9 v90 exec master..xp_regread n'hkey_local_machine', n'software\microsoft\microsoft sql server\instance names\sql' ,n'sql10',@spath output,no_output --step 4:preparing registry path declare @insregpath nvarchar(1024)=n'software\microsoft\microsoft sql server\' + @spath + '\mssqlserver\supersocketnetlib\tcp'; --step 5:enabling tcp protocol' exec xp_regwrite n'hkey_local_machine', @insregpath, n'enabled', reg_dword, 1 --generally tries enable addresses. not recommended --step 6:enabling remote access exec sys.sp_configure n'remote access', 1 go reconfigure override --reconfigure required! go --step 7:a system restart required in order enabling remote access. --step 7.1:shutting down server shutdown --after command need start server implicitly yourself. --or configure agent in order start server @ shutdown or failure
from:http://arashmd.blogspot.com/2013/07/sql-server-t-sql-tips-tricks.html#xp_regeditwrite
Comments
Post a Comment