Wondering the best approach to trying to connect to a Private AWS RDS Postgres instance. For me to connect with pgAdmin Ihad to create an SSH tunnel to the DB. I would like to be able to connect to this DB instance via a Java app from my local box and from our EC2 instances. I think the EC2 instance side won't be hard since they are in the same VPC and I think the security groups can talk, but how do you go about doing a SSH tunnel for the Java drivers?
Or perhaps I am looking at this all incorrectly? BTW this is NOT a Spring application.
Tried to connect directly to the server with pgAdmin. That failed, even with my IP added to it's security group. This is because for security reasons (no public API to the DB server) it is a Private server.
Will just create an API to update the DB when in DEV mode. Kind of an overkill but will keep things secure.
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
I have a pos software which is developed with java and it is running perfectly on localhost with a PostgreSQL database. But the problem is my client wants to use the pos software while he is travelling.
So my problem is how to access the PostgreSQL database which is running on localhost via internet. I searched this on google and found that I can use web services to connect to my PostgreSQL database via internet. But don't know how to access those web services via internet because I don't have an static IP address.
Can anyone please tell me:
What is the best way to access my localhost PostgreSQL database via internet?
If the best way is using web services how to access those services via internet if I don't have an static IP address?
I'm using java to develop my desktop POS software and it is running on a windows computer.
You would have the same trouble that accessing a box running PostgreSQL: you need to locate that box somehow; it will happens if you deploy your Web Services and it is happening now that you want to access your database. There are many ways to achieve that, but basically you need a permanent connection to the Internet (of course) and a static (real) IP.
I would recommend you to deploy your application in AWS, OpenShift, or Heroku, to name a few.
I am using sqlite for my offline J2EE applicaion . But I have two client and I want to connect database of two clients together .
Can I do it with sqlite or I have to change mysql ? And can you show me which host can help me solve this problem.
You cannot access SQLite remotely just using its native capabilities without some kind of an extra bridge, e.g ssh tunnel or a custom proxy daemon. MySQL and a number of other databases do provide remote access. There are a lot of hosting providers that manage MySQL for you, e.g Rackspace, Amazon, Bluehost, and many others, or if you just get a host with Linux and root access you can install it yourself, and there are many providers that can give you that - I personally like Linode.
Currently I have a Java application which performs all I wanted and the limitation
in it is "It only resides on the Local machine for which it needs to work". I have the Access Databases located on a Remote Server and I install the Java app on the remote server to connect the databases using a connection string jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=D:\\DATA\\DPPI\\DATA\\DPPI\\DPPIPR01.mdb;
It connects to Access Databases and do all the business logic with them.
Enhancements (to be done):
Making the application online - not a big issue.
Connecting the databases remotely - its the only concern.
If I make the Application Online the Access Databases need to be connecting through network (somewhat like IP or some web address).
Problem:
But after going through this Connect to Access database remotely It seems my requirement can not be completed.
Is there any way if I'm able to upload the database to the online web hosting server and access the database from there only? If yes, then how should I do the connectivity since Access Database connects by giving the fully qualified name containing drive letter and all.
But how should I proceed further so that I may be able to connect the mdb Databases remotely?
ADO Solution:
But after going through the link: http://webcheatsheet.com/ASP/access_connection_strings.php, it seems we can perform remote Access Database connectivity.
The solution for the ADO is something like:
connectionString="Provider=MS Remote; Remote Server=http://your_remote_server_ip;" &_
"Remote Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\your_database_name.mdb"
I'm a tad confused to how Access Database we can connect.
There is one more question in my head.
I'm making use of Type-1 Driver. Should the Type-4 Driver support the remote connectivity?
If your application is a server side application (like a web application) and your server's OS is Windows then theoretically it is possible to use your Access database. In this scenario, the Access database is local to your application. In your connection string you can simply use the path to the Access database inside your server's file system.
But keep in mind, that Access is a desktop database not made to use it as a server database. This can lead to poor performance and maybe system crashes. And it is possible that there are some licencing issues for this use case.
So even it may be possible to use Access with a server application it is strongly recommended to use a real server database like MySQL, MS SQL Server, etc. Even an embedded database like Apache Derby or H2 would be a better fit.
If your application runs at client side like a fat client, then your only chance to use Access is to put it on a network filesystem, so it is visible from every client. But this works only inside a LAN. If you cannot put it on a network filesystem then you have to use a real server database.
Do not use Provider=MS Remote (RDS) for new development. Here is a quote from the MSDN article
Microsoft OLE DB Remoting Provider (ADO Service Provider)
Important
Beginning with Windows 8 and Windows Server 2012, RDS server components are no longer included in the Windows operating system (see Windows 8 and Windows Server 2012 Compatibility Cookbook for more detail). RDS client components will be removed in a future version of Windows. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Applications that use RDS should migrate to WCF Data Service.
As others have suggested, you should seriously consider using a different back-end database for this particular application.
What if I'm able to call another java application residing on the Server housing the Microsoft Access Databases? Can you please let me know if it can be the solution such that I will have the division of my application into two:
1. The Online java Application performing 2 things: Accepting the requests coming in and waiting for the response to come from another application running on the Server housing the Microsoft Access Databases.
2. The Java application installed on the Server housing the Microsoft Access Databases only responsible for connecting and returning the DTO (Data Transfer Objects) -or some kind of objects in Collections.
So, I would expect a serverside program to handle the communication with the DB and the client application would communicate with the server app.
Please let me know if I should proceed in this manner.
it can be done by marking the traffic and queueing the traffic from the server---to----remote site ---(QOS..quality of service ) .....the two sites will be connected through VPN methods to reduce the unnecessary hops that will improve the latency plus add the security , thus server and remote site will logically act as if they are on the same network (LAN)
regards ,
Ali Rehan
Hi in order to access the db on my vps i have to previosly connect via ssh I have tested this with MySQL WORKBENCH and it works.
But Netbeans (working ide) does no provide ssh connection when creating a db connection so I cannot connect my local application to my new server.
How can I go around this?
How can i set my jta datasource to deal with this?
Thank you very much
Best Regards
Ignacio
There are two ways to archive connectivity from netbeans:
REALLY UNSAFE Method: Make MySql listen on the network-interface connected to the internet. Set bind-address in your mysql-configuration file to 0.0.0.0 and mysql will listen on all interfaces. http://dev.mysql.com/doc/refman/5.6/en/server-options.html#option_mysqld_bind-address You can then access MySql from everywhere on the internet. Remember: This is a serious security vulnerability! Search Google and you will find a lot of articles explaining in great detail why.
Safe method: SSH can do port-forwarding. It means, that one port on your local machine listens for connections and tunnels all traffic well encrypted to the remote port. On linux this is done with ssh -L 3306:localhost:3306 YOUR_SERVERS_IP. You can then access your MySql-Server on localhost:3306 like it is running on your local computer (just slower). On Windows Putty can be configured to do the same thing. I don't remember exactly where, but in the dialog where you setup your connection (before the command-prompt) you also can configure port-forwarding.
Write an application to run on your server, which takes care of Authorization and exposes and API to users (like the Youtube-api for example, which has some public methods but also some requiring authentication). This could be done in numerous different ways like XMLRPC (using a webserver and some web-application) or a custom protocol. This is probably the one most suitable for production use.
Poke some holes in your firewall to let NetBeans connect?
I would recommend you simply copy the database to your development environment and don't touch the VPS unless you're ready to 'release'.