How to access the jdbc driver from an online applet - java

My applet queries a mysql database, so I included the connector J jar in the eclipse project libraries and my applet runs fine in eclipse, but when i put it on the website, I get an error about that jdbc driver. When I made the jar of my project from eclipse, I don't think that the jdbc driver was included in the jar, so how would I access the jar? Should I put the jdbc jar inside my project jar, or have my project jar access the driver stored in its own jar.
Right now, I am using
<applet code="test.class" archive="math.jar" width=830 height=600 ></applet>

This isn't a good idea. You don't want an applet to access a database directly. You'll have to expose that port on the public Internet - not a good idea.
A better thought would be to put a servlet in between the applet and the database. Let the applet make the request to the servlet. It can deal with security, validation, binding, accessing the database, and marshalling the response.

Either put all classes from the jdbc.jar into "math.jar", or list it in the archive attribute: archive="math.jar,jdbc.jar".

Related

Where should we store database config files in Java Eclipse Dynamic Web Project?

I'm new in Java development and learning the basics of Eclipse environment.
Referring to the link, I got to know the folder structure of any web application (Dynamic Web Project).
I need to know the location of JDBC database configuration files having connection string, username, passwords etc.
Question: Should we keep the database configuration files (DAL) in WEB-INF and gain access from outside (I don't know how to do that) or should we keep the configuration files in src/package ?
JDBC database configuration files must be done in the Dao class ... which is a simple java class we dont keep the database config files in web-inf... WEB_INF is not used for this.. u must read some docs first about that...
If you use hibernate for the database.. then the configuration file is hibernate.cfg.xml which is placed in src/ Main/resources
and if you are using jpa(java persistence api) then
The persistence.xml file which contains the configurations of database is typically present in the src/META-INF directory of the persistence (JPA) project.

Birt: how to deploy a report in production?

I have just prepared a report with bird using eclipse plugin. It works.
Now I have deployed a birt 4.4 viwer on a Tomcat7. It works.
Now I put my report.rptdesign file insider birt folder under webapps in tomcat.
It does not work.
Obviously because:
the jdbc driver is encoded in report with full path that is obviously different from eclipse to tomcat;
birt needs a "org.eclipse.datatools_workspacepath" configured in tomcat (why????)
even if I configure above variable it complains about missing:
java.lang.NoClassDefFoundError: org/eclipse/datatools/enablement/ibm/util/ClientUtil
Yes I have used standard jdbc source (not "for query builder" one).
I would like to ask stack overflow why is so bloody complicated (and not documented) putting in production a simple report that uses a mysql jdbc jar.
Can you help me?
Thanks,
Mario
Well I don't understand all the question but I use birt with glassfish and jboss, you need to configure a JDBC in your server (I suppose you already have done that), then you have to change your Datasources erase all and use a JNDI URL with the name of your JDBC for example, if you create a datasource JDBC/test this is the JNDI url.
For the workspacepath I think this can be solved changing something in the birt war, go to META-INF and open the web.xml, then change this properties for another folders that have sufficient access permissions:
<param-name>BIRT_VIEWER_WORKING_FOLDER</param-name>
<param-name>BIRT_VIEWER_DOCUMENT_FOLDER</param-name>
<param-name>BIRT_VIEWER_IMAGE_DIR</param-name>
<param-name>BIRT_VIEWER_LOG_DIR</param-name>

How run java web strat application with hsql and glassfish?

I have java program with main function, that packaged into jar archive. There is dao class with DataSource. An jdbc url to data file is expected an is passed as argument to main function. Everything works as standalone application, but how I must link jar file with database when they both in glassfish? For example, I put jnlp into glassfish docroot directory, and put HSQL database file with populated data too. Whta link I must pass tho that database? If I simple replace
"C:\path"
with
"http://localhost:8080\path_inside_docroot_folder"
I get EOFException in java when it tryies to read a file.
Off topic:
Also it very strange, when I created hsql database I write something like this:
jdbc:hsqldb:C:\\path\db_file.dat
But actually in the path there is no exactly db_file.dat. There are several files, like:
db_sile.dat.tmp
db_sile.dat.lck
db_sile.dat.log
db_sile.dat.properties
db_sile.dat.scrip
Can anyone solve my problem? May files mentioned upper influence to the problem or it is pure glassfish deploy problem?
If something unclear ask me.
The answer is you can not run HSQL inside as static resource glassfish. You can run HSQL server as HTTP server or as servlet if you deploy web application. The solution for my problem is to put JNDI file and java jar file as static resources in glassfish and run HSQL server in the same computer (where glassfish is running).

how to embed javadb or hsqldb into java application with hibernate using netbeans?

I successfuly embedded javadb in my application using the classpath ,but here's the problem : I want hibernate to be able to work with the database,but I always get an error in netbeans sayng "enable to establish connection ".
AnyHelp please ?
The URL for a local HSQLDB database is jdbc:hsqldb:file:file_path_name The file_path_name is usually an absolute path with a name at the end. The database engine will then create a few files with the given name, but predefined extensions. An example of this is: jdbc:hsqldb:file:/mydata/mydb which will produce mydb.properties , mydb.script and a couple other files in the /mydata directory.

how to make my files present in a tomcat server to the browser

I have installed Tomcat 5.0 in order to execute a web application. How can I show my files which are present in Tomcat to the web browser? I tried http://hostname:8080/myfolder/login.html, but I can't see the files.
One more thing I know about JDBC and other database connectivity and I have developed a HTML page. How can I let a button in the page execute the code written in a Servlet and perform validations?
The simplest thing is to add to the root webapp. That is webapps/ROOT. Any file you put in there will be served unless you change the default configuration.
You should read about the details, of course.
I have installed Tomcat 5.0 in order to execute a web application.
First of all, why are you using the ancient (8 year old) Tomcat 5.0? If you can, rather grab the latest one, Tomcat 6.0.
How can I show my files which are present in Tomcat to the web browser? I tried http://hostname:8080/myfolder/login.html, but I can't see the files.
Is myfolder the context name or just a folder in your webcontent? If it's a context name, then you need to ensure that it's properly deployed. You can find details in the server logs in the /logs folder. If it is a folder in your webcontent and the webapplication is thus supposedly to be the "root" application, then you need to ensure that it's deployed as ROOT.
To learn more about using Tomcat, go through the documentation.
One more thing I know about JDBC and other database connectivity and I have developed a HTML page. How can I let a button in the page execute the code written in a Servlet and perform validations?
To the point, just create a class which extends HttpServlet, implement the doPost() method, define the servlet in web.xml and let the action attribute of the HTML <form> element point to an URL which is covered by the url-pattern of the servlet mapping in the web.xml.
As the question is pretty broad, I have the impression that you haven't learned in any way how to work with Tomcat and JSP/Servlets. I would strongly recommend to go through those tutorials to familarize yourself with JSP/Servlet on Tomcat and Eclipse (an IDE) first: Beginning and Intermediate-Level Servlet, JSP, and JDBC Tutorials
Tomcat is not a web server like, say, Apache. It's a servlet container. You can not just move file in a subfolder which seem to be what you did. You need to pack your web application in a .war and deploy it.
The URL should rather be http://host:8080/webapp/subfolder/login.jsp
Without much information it's hard to help. Please edit your question and describe what you've done so far.

Categories

Resources