I would like to ask a question about jar and database connection. I performed an application and converted to jar file. Jar file works if I open NetBeans's Service which is server(I have created my tables on jdbc:derby://localhost:1527/sample). But I want to open jar file without opening NetBeans and its service server. The application should work on other PCs if the jar file clicks.
I have searched a lot about this but I do not know how I can do. For example, if I use file database (MSAccess) with ucanaccess driver, will this support JPA(Entity Beans) and JDBC ? Because I have used JPA and JDBC together in my application. I have also searched embedded database but when I create the embedded database and table, I can not access table. It gives me an error which is "Table/View does not exist".
Please help me.
What should I do if I use JDBC and JPA together in my application ?
And If I want to open the jar file other PCs and they can reach database information, what should I do ?
Best regards.
I am new to derby+Netbeans, but from your explanation and this link -
https://netbeans.org/kb/docs/ide/java-db.html#configuring
It seems you are using internal Java DB which comes with Netbeans Glassfish server.
Therefore when you start the server from netbeans it works.
Try external installation of database as shown in the above given link. It should work outside Netbeans.
Related
I've been quizzing my mentor, but he isn't sure on the answer.
I'm building a JSP based application to be hosted on a tomcat server. It connects to several different types of SQL database. Where is the best place to store the drivers? We can't decide between adding to a lib folder in the application, or whether to add them to the lib folder of tomcat.
I'm using Eclipse to build the application and setting the buildpath for the app, rather than setting the classpath of the machine.
Thanks.
Db drivers normally go in the Container lib folder as different apps might use the same driver. Just to give you an idea an Application Server like JBoss provides drivers and libraries to connect to databases and other resources.
Another advantage it makes your WAR file a bit smaller.
I developed a java swing application by using hibernate connection and MS SQL server for database. Application is working fine. And I know the way to create and EXE and the installer for application.My question is, how I install this application to another computer with database. Should I install the SQL server on that computer or is there any way to use the db without installing the whole SQL server in that computer.
As far as i know there is no way of using database without installing the SQL Server, unless you configure in a way that the application will communicate with the db on your pc, but that's complicated
A different approach to this would be for you to make a view in the database and extract the data you need to a csv file, include that file in the resources folder of the application and then use Lucene to query over it
Take a look at how to get started: here
When you need to update the data in the file you can release updates for the application that would include these changes in the csv file/s
Recently, I constructed a java application that uses JDBC in order to connect to mysql. The question is this: if I export the java application as a jar file, does the database itself gets exported with the jar file? In other words, can the application still connect to the database (mysql) on any pc?
No you can't, JDBC is an API that defines how a client interacts with the database, it's a separate thing.
I've generated report with Pentaho Designer Studio. Using Maven dependencies my project has all libraries including pentaho engine and jdbc driver.
When I launch *.prpt file in Report Designer - all works fine, report is generated correctly. But when I'm trying to launch my web app - I become error that user authorization with my password is not working -> org.postgresql.util.PSQLException...
Question is why? All data needed to connect to database is in *.prpt file. In Report Designer everything works fine, in web app not. Can be that file *.prpt because of security reasons don't contains my password?
How can I include password into this file?
Test that you connect to your database from your web-application outside of Pentaho (for instance by writing a small JSP file that does nothing more than establishing a connection to your database).
If that fails, fix your database configuration. It might be that your web-server is not allowed to connect to the postgresql instance.
Pentaho Reporting uses standard JDBC connections and usernames and passwords are stored within the PRPT file, unless you use JNDI connections. For JNDI connections you dont need usernames and passwords as these details are provided by the application container.
Problem solved.
Of course I was connected to db from web app. Problem was that in Pentaho Report Design I had to give full path jndi name, not only "~JndiName~", so server could see it. That means - java:/comp/env/postgres. Using name postgres in apache configuration jndi naming works fine.
I found that tip after 2 work-days reading about...
I make a java application using netbeans that connect to database , but i have a problem , i want to embed mysql database with the executable jar file , so when i take this jar file and run it on any pc that doesn't have mysql server it will run with database , i thought about include the mysql-installer.exe and make a script to install the mysql server , but i can't find how to do that ,also i read about Connector/MXJ does it work if the user run the application and he does not have mysql server , any suggestion or article about this.
Derby is a pure-java DBMS. You bundle the derby jar with your program, just as you would any other library. This is a much cleaner way of ensuring your user has a db for your program, as you're not adding any dependencies.
Usually distributors don't include standalone databases, such as MySQL or Oracle, with their
application. If needed, they provide SQL script to build the database and make the user type in the database host, username and password and make a script to build the database. If you want to "ship" the database with your application then I would consider more lightweight databases such SQLite (singe file database).