apple-jdbc-web server - java

I'm a BSc student in CIT. I have a project in which I want to use a Java applet and JDBC in a sort of host/client.
My applet is working properly on localhost, but when I deploy it on apache webserver I loose the JDBC connection.
Questions:
Is it possible to use an applet with JSBC?
If yes how to do it?
Is there any web server in which to deploy applet and that supports jdbc connection?
My system: Fedora 8, NetBeans 6.5, XAMPP, MySQL.

You're probably running up against an issue with the Applet running in a sandbox, it can only communicate with the server from which it came - so if your database is on a different machine it can't be found.
A preferable architectural approach is to have your server do all the JDBC and communicate the information requested via HTTP to the client which is thinner dealing mainly presenting the user interface.

Yes its possible to use applet with jdbc.
Look here and here and here for possible ways of implementation.
Try googling for webservers, you will find tons of them, one lead is http://eatj.com/.
Rgds,
Aeon

Related

How can I allow other computers to access my programm's database?

I have a java application that I programmed, and I also created a Wampserver database to store the app's data. When I install the application in another computer, it basically can't do anything because wampserver isn't installed on that computer, and even if it was, the database wouldn't be imported on that same computer.
Can I install the database with the program itself, without making a database server in my computer? (For security reasons)
Sorry if this is a dumb question, im new to programming.
Assuming you are doing this in a Home/office environment. Where your IP Addresses do not change so often. Or you have the power to assign them statically.
You could try using a multi-threaded client server model. Where your wampserver computer(server) will accept a connection from another computer(client), and from there any queries to the database will be handled by that thread. This way, you could get away without installing wampserver on every client.
It would require some networking codes to be added to your java program. There are many examples on multi-threaded client server model -> Multithreading with client server program
You can open your MySQL server to the outside world or to certain IP (comment or edit bind value in your MySQL configuration file).
This can be a security issue. What is your objective? Usually, you'd do an API allowing access to your data from your application.
You are talking about "hosting" your database. You need to either:
Create, develop, and run a hosting service (not trivial), or
Pay to one the myriad of hosting services available, and install your database there (cheap these days). Just a couple of well known examples: Digital Ocean or Amazon Web Services.
In any case, it's a huge security risk to open your database to any client online.
Normally you write a program/application that accesses the database in the same [local] network, and that application serves web pages (or other web service) to the world.

How to embed database derby in jar file

I do not want to install a database server on target machine. It is possible that we can simply ship a jar file with the database embedded in it, and not worry about installing a database server separately?
I created one application in netbeans using derby and it is working fine in my pc but when i am running on other machine it is giving me Error connecting to server localhost on port 1527 --> this error says that there is no Database running on port 1527. but i dont want that the client should take more efforts to start DB server and all technical process. It should be simply runnable when i start application Derby DB should start and when i close DB should close.
So what will be the solution for my problem?
And one more Question is Can i use derby database for large scale projects?
No, you don't have to install a database server on the target machine; Derby works just fine in embedded mode without a separate server.
However, if you want multiple client applications to be actively sharing the same data in the same database, you'll want to use the client-server mode, not the embedded mode.
And yes you can embed a jar with the database into your program. If you want to know how, read this documentation: http://db.apache.org/derby/docs/10.11/devguide/cdevdvlp24155.html
And yes you can use Derby for large scale projects. But it doesn't come with all the enterprise features (online backup, etc.) that a true enterprise scale commercial DBMS comes with.
But, since it sounds like you are just getting started with Derby, can I suggest that you please start with the Derby tutorials before you try these advanced configurations? Here is the link to the Derby tutorials: http://db.apache.org/derby/docs/10.11/getstart/
It may not be possible to give you very good advice without knowing a lot more about the application you're trying to build and the overall architecture you're trying to use.

Connecting Access Databases remotely?

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

Java Socks5 External Application

I have connected to a socks5 server in my java application, and now I want to launch an external application and have all of its connections run through the socks5 server. The external application itself doesn't support socks5.
Any input would be great, scratching my head here..
The 2 trick I know how to do that are to replace the standard runtime library or a similar trick to intercept the OS networking calls or to setup a set of finely tuned firewall rules in the kernel.
Both of these techniques are very OS specific and have no way to da that using java.
Your best bet would be to run an existing socks5 wrapper and let that program start the external application like socksify.
I have had mixed experience with this approach, some applications work, others do not, and never found any logic in it.
YMMV
Another approach is to play a tcpproxy in the Java application (e.g. using the Apache MINA stuff) and have the application connect to your proxy port on localhost. Again this will only work for certain services.
If the external application is written in Java it does support SOCKS. Just run it with -DsocksProxyHost=host and -DsocksProxyPort=port. See [1].
[1]: http://download.oracle.com/javase/6/docs/technotes/guides/net/properties.html "Networking Properties".

How do you start derby in network server mode and still get an embedded connection?

I just want to know how I can start derby in network server mode and still be able to get an embedded connection?
Thank you.
You need to launch Derby in "embedded server mode". If you are already using Derby in embedded mode, this can be enabled by providing the necessary files in your classpath, then specifying a handful of command line arguments when launching the application.
First make sure the following jars are in your application's runtime classpath.
derby.jar derbynet.jar
Then add the following command line options to the Java command used to launch your application. If the class files are missing, these options will have no effect.
-Dderby.drda.startNetworkServer=true
-Dderby.drda.portNumber=8011
I'm running Derby from within a servlet hosted by Tomcat, so I added these options to the catalina.bat file.
Start up your application and check the list of open network sockets.
netstat -an | find "8011"
You should now see Derby listening for connections on 8011. Its now possible to connect to the database using Derby's client driver (derbyclient.jar). The instructions at http://docs.oracle.com/javadb/10.3.3.0/adminguide/radminembeddedserverex.html cover this part pretty well.
It was hinted that running Derby in this mode may be discouraged. I don't believe that to be the case. Your application will continue to access the database using the embedded driver, while other software is now permitted access using the client driver.
The Embedded Server mode sounds like what you are asking for. It allows you to start a network server when you start the embedded database.
It sounds contradictory that you want to start derby in network server mode and get the embedded driver. Even if this might be possible, it is definitely discouraged. You should decide on whether you want to use Apache Derby in the network mode using the DRDA or as an embedded driver and stick to that decision.
Here you'll find a tutorial on how to use the network driver:
http://db.apache.org/derby/papers/DerbyTut/ns_intro.html
Some one correct me if i am wrong, Both will run on separte ports. So you can connect to the required one using the proper connectionName, right?
#pawelocue: Sorry, but this is wrong. Using the embedded server mode is perfectly alright and sometimes very useful. It is definitely not discouraged.

Categories

Resources