Placing JDBC Driver to work with Java class In a Webapp - java

Im trying to set up the JDBC driver to work with a Webapp. I did manage to make it work with my java class but it must be aside from the webapp. In a single project apart while compiling in Netbeans. I've to make it work with a webpp using Tomcat. Im in the part of validating user login info using the data stored in the Database. I send the user info to the server side (Java class) to validate as I'm in favor of not using scriplets in the JSPs so I dont want to re-code the same functions I have in my Java class. Where do I put the driver so that it can be used in the Java class in webapp? I tried in Tomcat/lib and Tomcat/common/lib. Im using LINUX Ubuntu.

In your webapp under WEB-INF/lib

Never mind, I found the folder. For future users in need, you must place your JDBC driver in:
**/usr/share/tomcat7/lib**
NOTE: This is in Linux Ubuntu.

Related

Is it possible to make Camunda Webapps (Spring-boot stand alone) update .bpmn through Tasklist via DB or Rest

We are trying to deploy Camundas webapplications as standalone spring-boot application and also deploy .bpmn diagram and engine in another stand alone Spring-boot application. But only connect the two SB-apps via a shared DB or REST-calls, and still be able to update the task through Camundas webapplications.
We have managed to deploy them and connect them to a file based H2 database. So now we can do rest-calls to the .bpmn Spring-boot app and submit forms etc. and then make it show in the Webapps-tasklist/cockpit.
The problem is that if we try to submit the form through the tasklist, we get an error that it’s trying to look for a javaclass (which we have implemented in the engine-SB-application but not in the Webapplications-SB-application).
Is there any way to make it so that we can use the web-apps-tools and submit the form from there (without changing that the .bpmn diagram uses java-classes)?
Either through making the webapps update the database, or maybe through REST-calls?
We solved it by using Asynchronus Continuation.
A very good video about can be found here:
https://www.youtube.com/watch?v=Nx4I8lNMUs0

Shared Database in application and webserver

I wrote an application which uses a SQLite database, now I want to extend the apllication with a webinterface.
Since I want everything to be in one application with no need to set anything up or install something else I plan to embed Jetty in the application and then install some CGI servlet to use PHP.
The application and the website should be able to modify the database.
This is most likely not to be accomplished with SQLite.
What ideas do you have to accomplish this? Important is that everything can be integrated into one application.
Ensure you access the database only via a javax.sql.DataSource definition from JNDI, and you are golden, as both sides, both the Application and the WebApp will have the same access patterns, techniques, rules, etc ...

Web Service with Java 1.6 and Tomcat6 in Debian / Linux

I tried to develop a very simple Java WebService with Jdeveloper 12 (a single string variable with getter and setter). I tried debugging it on Windows and all went fine (I can get and set the values on the variable).
I created the ".war" file but when I try to develop to tomcat (with basic configuration)
I can't see it on available webservices nor I can't access it...
I'm trying to develop it on Debian 6.0.7.
I didn't find the settings to change the port where the webservice is listening on too.
I'll accept tutorial with Eclipse or Netbeans.
Does anyone know a guide or a complete tutorial from the developing to the deploy of the web service? I need to know how to configure the various .xml files to let it working..
I Assume you are trying to deploy to tomcat. Have you used any frameworks to convert your java program into a web service? Is there any " .wsdl " file which you can locate?
Create a java class with a string variable setter and getter
Expose this class as a webservice (Can be done by any frameworks ex: axis, cxf etc.)
The framework provides with a wsdl file and a war if you built it.
Then deploy war file to any server.
Did you miss the points 2 & 3 ?

How to connect MS Access database to Java Applet

We have to create a Java project on ATM Mechanism. We plan to connect it to a database also.
Could you please help me as to how I can connect an MS Access database to a Java applet which we have created using BlueJ?
Thank you.
Connecting the applet with MSAccess would be very complex, because of applet security limitations. An applet is not supposed to access local resources (files), so you would have to add all kinds of signatures to the applet for the browser to allow this (I did something like this about 12 years ago, and from my knowledge, the applet security limitations are still in place, or even worse).
But if you do manage to access the local filesystem, you can use some library like Jackcess or access the mdb file directly using jdbc/odbc driver as shown here.

Web application cannot establish connection to database

My application, when running on Tomcat, is not able to connect to my database when deployed as a .war in the webapps folder, but it can connect when I am running it through Eclipse directly. The code is exactly the same in both cases. In addition, other apps in the webapps folder, which originally could connect to the database, can no longer do so. The jdbc code is correct as I have tested it with offline applications or when running it through eclipse, but not when I access it on, say, Chrome, using localhost. What has happened to my tomcat server?
Note: the JDBC driver is the MS Access one.
The code is exactly the same in both cases.
No it's not; if it were exactly the same you'd be connecting properly.
but it can connect when I am running it through Eclipse directly
Does this mean that you have a main method that drives the code that connects properly? The way you do it is usually different from a web app - you know that, right?
If you could post an exception or log message it would help a great deal.
I'm guessing it could be any one of the following; guessing is necessary because you haven't provided enough information for a solid answer:
The JDBC driver JAR is not available when you run under one configuration; you'll see a ClassNotFoundException in that case.
You haven't configured a JNDI data source properly in Tomcat.
You didn't put the JDBC driver JAR in the Tomcat /lib directory.
Could be other possibilities.
UPDATE:
Since you're using Access, and providing no other information, I'm guessing that you're using a relative file path to get to the Access .mdb file. Your command line app that runs successfully in Eclipse works because you give a relative file path that is correct relative to the project root. When you deploy to Tomcat, that relative path is no longer correct, so your application can't find the database anymore.
Sounds like you aren't printing the stack trace for errors, so you're losing out on information that might help you figure this out.
Microsoft Access is not a multi-user database. A web based application running on Tomcat is certainly multi-threaded. You should not be using Access for a web application. I'd consider switching to another database.
First, you need to verify the path to your database file. In fact, I believe it has to be an absolute path for tomcat to work correctly. The simplest thing to do is to put your database file in C:\data or similar and then hard code the path in your code. Of course, the file will be outside of your war and thus not portable (i.e., deployable to a remote server).
Second, you do need to make sure that the JDBC driver is available. If you use Class.forName in your code to load the driver, you will only need to make sure that the jar containing the driver is in the tomcat classpath (which would include the lib directory of your webapp). If you use the -Djdbc.drivers JVM flag approach, you will need to add it to the tomcat startup scripts.

Categories