jdbc sqlserver url string - sql-server-2008

I've found this in a software developed by another with j2ee spring_hibernate tomcat_v7 and jre7.
the dbURL is written as follow
dburl = "jdbc:sqlserver://remoteip\\local\\local:1433;database=dbname"
what does the double local means? when removed them the link to sql server 2008 doesn't work anymore.

simple answer to this is in the "integratedSecurity=false;"
when you want to connect to the database installed in the same machine and by the windows authentication then use "integratedSecurity=true" without login or password while you have to put the dll existant in the auth file in the jre lib directory
however if you want to use another machine (remote) this time the integratedSecurity will never work so you will have to choose the sql server connection and then absolutly use "integratedSecurity=false"
String connectionUrl = "jdbc:sqlserver://ServerName\\databaseInstance:1433;databaseName=DBSS;integratedSecurity=false;user=user;password=pass";
you may also open the sql server config manager and set TCP/IP to enabled, the ip adress (IPALL) dynamic to nothing (delete the 0) and the port to 1433 (same as the string connection) and restart the sql server service
you'll probably also need to create a firewall unbound rule for that port.
hope this will help others.

Related

How to access my newly setup MySQL database (getting "Domain is currently unable to handle this request.")

I just set up a new MySQL database with the MySQL workbench & created a user for it with all necessary privileges. I am using this database for use with my php code. But I can't seem to connect to it on my live server (pages are hosted on windows server 2012). Everything works fine in my local environment with xampp and the new MySQL database is exactly the same as the xampp one. I think I am maybe using the wrong host name or something. As host name I copied the name that is displayed after "Host:" when you click on Server Status in MySQL workbench. The database name, user & password should all be correct. But when my code tries to access the db I get a "The domain page isn’t working. Domain is currently unable to handle this request."
You either have no network connection to the server at all or it is blocked due to firewall or routing misconfiguration.
If you do have network access in general, you might forgot to
FLUSH PRIVILEGES;
or you have not enabled networking over TCP, the default is to listen only to localhost (on unix systems via unix sockets, on microsoft I guess it's simply TCP).
Read about the following configuration parameter which will solve your networking issue:
bind-address
If you have a very old MySQL server version, the parameter is enable-networking but it shouldn't be the case anymore.

Access MySQL server from Grails

I like to setup a dedicated MySQL server in a LAN accessible from other computers of this network. How can I setup the database server and the clients?
How can a Grails application can access the MySQL from the same LAN?
If your MySQL server is going to run on Windows then you can configure it with the installation program. For example, I downloaded the install file mysql-installer-community-5.6.20.0.msi (versions change quickly) and it offers the option of installing just the server:
Just follow the screen prompts and take all the default values (strongly recommended). The main values to remember are:
The default network port number 3306.
The server's ip address.
The username(s) and password(s) that you created that have access to
MySQL.
Then I suggest you download HeidiSQL and configure a connection to your new MySQL server, that way you can manage your database server remotely:
Hope that helps.
You are asking 2 differents questions.
To set up mysql connection in your grails app, did you at least try to read the doc ?
http://grails.org/doc/latest/guide/single.html#dataSource
It's just a jdbc connection string :
https://www.google.fr/?gws_rd=ssl#q=jdbc+mysql+connection+string+example
It's more than just the JDBC connect string. You won't get far without a driver, so uncomment the sample entry in BuildConfig.groovy in the dependencies section and update the version to the most recent:
dependencies {
...
runtime 'mysql:mysql-connector-java:5.1.34'
}
Set the driverClassName in DataSource.groovy, along with the correct JDBC url for your database. Replace <server> with the server name or IP address, and <dbname> with the correct database name. You will likely also want to add parameters at the end of the url in the querystring. And if the port is non-standard (3306 is the default) then add that in also. To ensure that you use INNODB tables (older versions of MySQL default to MyISAM), specify the MySQL5InnoDBDialect (or a subclass):
dataSource {
...
driverClassName = 'com.mysql.jdbc.Driver'
dialect = org.hibernate.dialect.MySQL5InnoDBDialect
url = 'jdbc:mysql://<server>/<dbname>'
}
Run grails compile to download the driver jar and setup the classpath.

Connecting to SQL process with Zend

I'm trying to connect my Zend application to a MySQL process running on a shared server. The basic config should be fine, as it was working with a LAMP server.
The problem is, I need to specify the host as being the an sql process: myprocess.db, rather than localhost:
resources.db.adapter = PDO_MYSQL
resources.db.params.charset = "utf8"
resources.db.params.host = mysqlprocess.db
resources.db.params.username = username
resources.db.params.password = password
resources.db.params.dbname = dbname
However, when I do, I get this:
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]:
Can't connect to local MySQL server through socket 'please_see_the_faq' (2)
in /f5/metamusic/protected/application/controllers/SearchController.php on line 418
The host I'm using is NearlyFreeSpeech, and this message is apparently triggered when attempting to connect to SQL without specifying the process you're interested in:
http://faq.nearlyfreespeech.net/section/mysql/mysqllocalhost#mysqllocalhost
Using the same details and mysql_connect($server, $user) works without issue, so it looks like Zend is somehow not using the correct host parameter.
Any ideas what's going wrong? Any help would be much appreciated.
try using
resources.db.params.host = myprocess.db
The host in the db config has to point to a database server. localhost or 127.0.0.1 are references for the database being on the same server as the application. In a hosting environment you usually have the server on a remote server so the host has to be either an IP address or a DNS name for the host.
Check the second question in the FAQ.
Update
My bad, that is about DSN and not DNS. Still, that's where the problem is. The resources.db.params.host directive in the config expects a reference to the database server and myprocess.db is neither a DNS name nor a IP address. You probably need localhost for that but then you will still be missing the DSN. I currently don't see how you set a DSN in PHP for MySQL and therefore Zend. Have a further look at this MYSQL DSN.
Update 2
You are correct with the socket and that this is related. I think the problem is the Zend PDO_MYSQL adapter. Zend funnels this directly to PDO(). There are this additional config options I mentioned above (MYSQL DSN) which is missing in the Zend implementation. Although the PDO_MYSQL adapter overrides the connect() method it does not look for this options.
However, there is another adapter mysqli which connects directly to MySQL and actually the same way as your test with mysql_connect(). It uses mysqli_real_connect() instead and that connection might understand the process name for the socket. So, you can try the following in your config:
resources.db.adapter = "mysqli"
I'm posting my eventual solution here for future reference:
It turns out, the database connection was already working. However, my call to mysql_real_escape_string() was failing, and the resulting error message suggested that the entire database connection had failed.
The solution was simply to replace the above call with Zend_DB_Adapter's quote(), and suddenly everything works.
Why this works on a LAMP machine and not a shared server, I have no idea. For now though, this is a good enough solution!

SQL Server connection string to a remote server

I have a remote SQL Server Express (2008 R2) with an IP: xx.xxx.xxx.xx and an instance name: myInstance.
I have been trying to connect to a DB (myDB) as user (dbUser) and with password (myPass).
I have tried various string combinations but none works. I am sure I got it wrong because the server is ok, I can ping the IP Address, SQL Server runs on port 1433, which is open. I have also enabled browser service and remote connection on the server.
Please someone give me the correct string...
How to: Configure Express to accept remote connections
There could be many reasons for this, however, you didn't post any useful details such as error messages or what exception was thrown (if any).
Check that Windows Firewall allows access on port 1433 - this is the most likely reason for the failure, since you are using an IP address and not the name of the instance.
I suggest looking at http://connectionstrings.com to check your connection string.

How can I connect to Sql Server 2008 remotely using an IP Address?

When I publish my project clients will need to be able to setup the initial configuration, and part of that is the Sql Database Connection. I have an instance of Sql Server 2008 running on my system (MSSQLSERVER2008) as well as SQLEXPRESS2005. I am trying to use the following connection string locally just to see if this works, and I can't get it to work:
ConnectionString = {Data Source=127.0.0.1;Initial Catalog=DCOMProductionsDesktop;Integrated Security=False;User ID=DCOMProductionsDesktopService;Password=;Network Library=dbmssocn}
The error I get is the usual "The target machine actively refused the connection".
*There isn't any firewalls running, and its inside the network anyway
*TCP/IP Protocols are enabled
*Remote Connections are enabled and permitted
So, I'm stumped.
Edit
I changed the connection string's data source to:
DataSource=192.168.0.2\MSSQLSERVER2008 on my WinXP VM (for testing remotely)
Now, this did work. But when I deploy this across the internet, will that same connection string work for clients outside my network using a domain name such as:
DataSource=desktop.dcomproductions.com\MSSQLSERVER2008
Or will I need to do something different?
It will work, as long as "desktop.dcomproductions.com" or whatever, resolves to the proper IP address. So that name should be set up either on the public or private DNS properly.
Also, make sure it resolves to a public/external IP address, unless your client's scripts are going to be within the same network as the SQL server.
Thought I post it as an answer, instead of comments :)
It's been a while sice I used anything but Named Pipes to connect to a sql server instance so this may not be relevent but try changong Data Source to Server.
They may be synonyms, as I said, it's been a while.
Also, even if you are using an IP address, you aren't specificying an instance of sql server to connect to, that may also be causing issues