wired based remote mysql server connection with user and password - java

I am working with two system in wired internet. One is mysql database server and another is java client application. Both computer are connected to internet via wire. So My problem is , I can not connect to remote server using username and password. But with Netbeans IDE i can able to connect but after making jar file i can't not connect?
my connection code is : "jdbc:mysql://192.168.2.107:3306/db_store", "user", "pass"
What would be the problem ? and how can i solve it? thanks.

Related

I can't get Android app to connect to XAMPP Localhost

I've tried and searched the internet.I am very new to this so....
Does anyone know how to connect an Android app to a MySQL Database WITHOUT PHP?
I am using a PrintWriter and flushing two strings to a XAMPP Server Database,
I personally don't like using PHP err (referenced variables that don't even exist)
Basically I just have an app that sends login data to Server Database but I want to test it
any help appreciated!
QuestionOverflow
I see here misconception Of what the PHP is and what MySQL Database for and the real question is "Is it possible to connect to MySQL database from android app?"
And the answer is NO. but why ...
We have android app which run on Mobile Device --> (client)
And server which runs MySQL Database Server --> (server)
The problem here is that the MySQL database server doesn't show it self to public to all clients.
Only programs that runs on the server can connect to the MySQL Database.
But how to save and get the data from my database ??!!
You should need a http end point like PHP that will be available to the clients and will connect to the MySQL Database and get the data and return them to the client (mobile app).
And if don't like PHP if you master it you will like it check this tutorial
enter link description here

Connecting different user to 1 server(database derby) in netbeans using java

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

Establish MS SQL 2008 connection with JDBC using domain credentials

I have three servers, App Server, Domain Controller and SQL Server. All of them are connected trough the local network.
What I am trying to accomplish is to successfully connect my app to the database using the credentials of an authorized domain user (ex: dom\dbadmin).
When I connect locally using those credentials, it works.
When I run the next code trough CMD on the APP Server with the right credentials and local IP, it works!
RUNAS /user:dom\dbadmin /netonly "C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\Ssms.exe"
But when I try to connect with my app to the database with the following connection string it does not connect.
jdbc:sqlserver://10.20.30.110\MSSQLSERVER;databaseName=dBase;user=dom\dbadmin;password=!8899#te$t;
I have successfully made a connection to a identical DB but with SQL credentials and a remote ip and it works.
Am I doing something wrong? Or is it just not possible to make a connection with JDBC and domain credentials?
As far as I know - for passthrough authentication to work (SSPI in connection string) - you'll have to allow the domain controller to make the decision to allow you in with your credentials or not. In order to make this decision the controller will reply on your windows authentication with all imposed security restriction on computers within that domain. If you are logged on a computer as CORP\UserName then SSMS will not allow you to connect as someone else such as MyDomain\OtherUser. That is even if you know the correct password.
If you need an application to connect to an SQL Server you'll probably have to enable mixed authentication on the SQL Server and then generate an application password (not relying on Windows authentication).

Connecting to database on users computer

I am currently using Netbeans 8 and trying to make the MySQL database connect to the program without downloading MySQL on to the users computer or running a server, so the MySQL file must be local. How may I proceed is there a way to package with the jar of the program or should I proceed another way.
Also here is the code that connect to the database.
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/chutesandladders", name, password);
Statement update = conn.createStatement();
It is not possible to package a MySQL "file" in JAR. MySQL always runs as a server process that you can connect to using JDBC.
The JDB URL dbc:mysql://localhost:3306/chutesandladders from your question contains the hostname localhost and the port 3306 where the MySQL server is running.
If you want a client on a different machine to connect to this server, you must use the real hostname of the server in the JDBC URL. Of course you must allow access from this client to the server.
Edit: If you must use a relational database but can not access a server, you should use an embedded database. A widely used is H2.

do i need a tomcat server to make java jdbc swing application to run on lan

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.

Categories

Resources