I am using sqljdbc4.jar for connecting SQL Server 2008 with java application using Windows authentication. Everything works perfectly up to date until I tried to run the same code with SQL Server 2012.
After research, I came to know that I need to enable the TCP/IP. But my problem is, my applications will be distributed to users in the form of .EXE and users will install the application themselves. Also, all users will have the SQL SERVER 2012 pre-installed, my application is not supposed to install the sql server.
Now my question is, how can I connect to SQL server without enabling TCP/IP manually? I heard about shared memory protocol also, but not sure how its connection string will look like?
I am using below connection url till SQL Server 2008:
jdbc:sqlserver://localhost;instanceName=SQLServer12;databaseName=Test;integratedSecurity=true;SelectMethod=direct;responseBuffering=adaptive
Please give your suggestions so I can try it here. Thanks in advance.
Try adding the property Network Library=dbmslpcn; OR Net=dbmslpcn; to the connection string for Shared Memory. The default value is dbmssocn (TCP/IP).
Network Library: The network library used to establish a connection to an instance of SQL Server. The corresponding network DLL must be installed on the system to which you connect. If you do not specify a network and you use a local server (for example, "." or "(local)"), shared memory is used.
I got this from: https://www.connectionstrings.com/all-sql-server-connection-string-keywords
Related
I made an inventory system in netbeans using the language java and i connect it to derby as my database it is already working as a whole system but I want to have a client-server functionality what I mean is I want my program to have a server which holds the database(different computer) and different users with different computers which they can save/view data at the same time to the database means they are connected in one network.
Working with multiple connections to a single database.
What code can I use or method or do I have to import something?
I did some research and the only thing that I found is socket which can be used to create a chat between server and a client.
But I only tried the IP 127.0.0.1 for the client since I am making running the server and the client in the same computer.
And also can I open the connection of the server in the client form and send data like SQLQuery so I can save it in the database of the server?
Where can I see examples for these? Please help thanks
Yes, Derby supports a client-server configuration of your application.
Deploying your application in the client-server configuration is straightforward:
Deploy the Derby Network Server, for example by running the startNetworkServer script that is included with the Derby distribution.
Ensure that derbyclient.jar is in your application's CLASSPATH, and that you register "org.apache.derby.jdbc.ClientDriver" with the JDBC DriverManager.
Change your JDBC Connection URL from jdbc:derby:<db details> to jdbc:derby://<host:port>/<db details>.
If this is your first time using Derby, I strongly recommend working your way through the Derby tutorial at https://db.apache.org/derby/docs/10.12/getstart/index.html
For more information about running the Derby Network Server to service database requests for your applications, read the Derby Admin Guide: https://db.apache.org/derby/docs/10.12/adminguide/index.html
Use the IP 0.0.0.0 or for all connections in the server. The the connection url should include the name of the server or the ip address of the server in the network. When you use ip 127.0.0.1 or localhost derby can only accept connections to the database in the same machine, in this case localhost. All of this can be done by your network application server
So I'm working on a project using a SQL Server 2008 database. It uses Java with Hibernate. I was doing some work on it last week, it was working (relatively) fine. I came back to it today and all of the sudden Hibernate can't login or connect to the database. I suspect the problem is in SQL Server because I tried connecting to it with JDBC but that didn't work either.
Server authentication is set to "SQL Server and Windows Authentication mode"
my users "dummy" and "root" have "Grant" check on all explicit permissions.
The username and password I enter are correct. I know this because I can log in o SQL Server Management Studio with those logins and run queries.
The database is on a Windows XP virtual machine and I'm using Eclipse on my host machine. I have Port Forwarding and everything set up with Oracle VirtualBox (like I said, it was working fine last week).
Any suggestions?
--EDIT--
See the comments below the original post
---EDIT---
I made a discovery. My Java project is not even getting connected with the SQL Server. When I fail a log in with a .udl test, a log message is created for the failed login. But whenever I fail to login using my Java project on my host machine, there are logs created.
I should also point out that I can connect to a MySQL database running on the same VM and run queries on it just fine.
Is there something wrong with this URL String? "jdbc:sqlserver://192.168.56.1:1433;databaseName=MLB;user=dummy;password=123"
I can confirm that the IP Address, Port number, database name, username, and password are all correct.
I figured out the answer myself. I had install SQL Server 2014 on my host machine and somehow that conflicted with some settings somewhere. Once I unistalled SQL Server 2014 from my host machine all of my problems went away.
I am attempting to create a MySQL and Java client app for my home network.On the server machine I successfully connected to the MySQL as root
Now I want to connect to MySQL from my client PC using the Java client program,
How to do this??
Do i need to install Tomcat Server to run on server for this.
I am using Windows 7 on all my clients and server machines.
Tomcat server is used for web applications.You just need to create a JDBC code and in the URL string just give the ip address of the system where mysql is installed.For example
connection = DriverManager
.getConnection("jdbc:mysql://192.168.1.205:3306/database_name","root", "password");
Also if you have not granted the permission in mysql then grant it .See this for granting permission for access to mysql on remote system
Depending on what you want to achieve, you need to establish a JDBC connection to the server. Take a look at the JDBC trail for more details.
This will allow you to connect directly from you client machine to your database server. This would be done using the required JDBC connection URL for the MySQL connection, for example jdbc:mysql://[host][,failoverhost...][:port]/[database] ยป
[?propertyName1][=propertyValue1][&propertyName2][=propertyValue2]..., check out Driver/Datasource Class Names, URL Syntax and Configuration Properties for Connector/J for more details.
You may also need to configure your MySQL server to allow remote access before you can connect
You just need to do two things:
Make sure the server hosting MySQL allows incoming connections
Write JDBC code and use your MySQL server hostname/ipaddress in the jdbc string to connect and use it.
I am attempting to create a MySQL DB and Java client app for my home network. I haven't really had any experience with MySQL other than PHPMyAdmin for a website backend (also have used SQLite). I have downloaded the full MySQL installation and a test DB from the MySQL website. On the server machine I successfully connected to the DB as root. Not a difficult task.
Now I want to connect to the DB from my client PC, just to check I can. Eventually I will use the JDBC driver to connect from my Java client app, but before that I just want to check I can connect.
How should I do this? SHould I just install the MySQL command line program onto the client PC?
EXTRA INFO: forgot to add, I'm using Windows 7 on all my machines.
Yes, you could install the MySQL to get MySQL command line program and connect with it, but also you can use another MySQL client tool like PHPMyAdmin, dbForge Studio for MySQL or another one.
To connect from remote host you should create special accout for it, e.g. - 'user_name'#'your_host_name'. Find more information here -
Specifying Account Names
Account Names and Passwords
I have a site running a Linux/Apache/MySQL/PHP stack. I would like to connect to the database from a locally run Java program. Is this possible? (Deploying the Java program to the server would be a great effort.)
Yes, of course; as long as the Java program has the correct credentials, that the user it logs in with is given proper access from the database, etc.
From the perspective of the database, it has no idea who is connecting to it or what technology they are connecting from - all it sees is just another connection.
See Establishing a Connection in the same JDBC tutorial I linked to earlier.