I have designed a Java derby database application. It had the dbproperties file. I'm creating a database file with these properties. Even it had username and password. The database is accessible in razorsql without any authentication. Suggest me where I'm missing.
creating Database
dbproperties
Related
I have a simple spring boot application. I am using JDBC connection configured by JDBC Template (JDBC url is got from properties file).
Can you tell me how to reach following thing:
JDBC Connection should be established in depends on logged user, I have a problem with projecting in spring such flow of control that object jdbc template will be created after loggining user.
It is about different users use different database.
Can you help me, please?
You can do the routing at the datasource level.
See https://spring.io/blog/2007/01/23/dynamic-datasource-routing/
And
http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/jdbc/datasource/lookup/AbstractRoutingDataSource.html
Here I found a simple vertx project that uses apache-shiro for auth.
Here the user informations are stored inside src/main/resources/vertx-users.properties file like this:
user.tim = sausages,morris_dancer,developer,vtoons
role.developer=do_actual_work
role.vtoons=place_order
Is this a good approach to store user name and password in a file? Can we store these information in encrypted format or anywhere in a database. Can apache-shiro access these info from a db?
Please provide if you have some sample projects
Better use LDAP or DB
use blog
http://meri-stuff.blogspot.in/2011/04/apache-shiro-part-2-realms-database-and.html
for reference
Also this stackflow post Configure shiro.ini for JDBC connection
I am trying create a swing application with embedded database using netbeans IDE. First in the netbeans services tab i have created a database and connected using embedded driver. Then i have created all the tables and relationships there.
In the swing application i connected embedded database like this
private static String dbURL = "jdbc:derby:derbysample;create=true;user=root;password=root";
Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
//Get a connection
conn = DriverManager.getConnection(dbURL);
This creates the database and i could able to connect. But i doesn't create tables that i created. It's is standalone application. So for different machines it need to create database and tables. There are many solution?
Create programatically tables [Add another java file to create tables and relationship]
Get Schema of Database and build it.
My Question is "is there any easy way to add database structure to embedded database in standalone application?
Abstract of question is:-
Using a derby embedded database with large number of tables and relations. What is the best solution?
Create tables Programaticallly - How can i make it as runs only one
time for each install
Use ant build tools to generate tables
Is there any other ways?
Am assuming what you want is to create a database with specific tables during installation and use the same afterwards.
Derby is light weight database stored in single directory. Having said that creating tables is as simple as executing create table sql queries. Run this while you install.
create=true; in connection string means create an empty database if a matching one is not found (at the given path). This should be done only done at the time of installation.
You mentioned that you created the database with tables. While connecting from application you got an empty database.
Looks the application is not able to access the previously created database at given path (derbysample directory at working directory) and is creating a new database. Try giving the full path without create=true in connection string
private static String dbURL = "jdbc:derby:d:\\somepath\\derbysample;user=root;password=root";
This will force application to use an existing (previously created) database and throw an exception if the same is not found.
There is an already existing Java project that extensively uses Hibernate and Spring. And for unit testing it uses an in-memory HSQL data base. I am trying to figure out WHERE this database is getting populated from.
Can someone tell whence I can start looking? Or how to find the file containing the script for creation the tables?
Btw, the tables DO get created. That I confirmed by opening the Database Manager.
If your connection URL begins with jdbc:hsqldb:mem: then this is not populated by HSQLDB but by Hibernate or Spring.
If the connection URL begins with jdbc:hsqldb:file: then the specified file path is the location of the HSQLDB .script file.
I am connecting to an external database (i.e. Oracle 10g) using my Play 1.2.4 application.
I have provided all the DB details in the application.conf file, then added the ojdbc.jar in the classpath and the connection seems to work fine. But the problem is everytime when the application access some data for the first time. it is trying to create the entity table (which is already present) and hence throws an exception.
I don't want to create any table since its already there with some data, hence how can I avoid this?
There might be some configuration to set in the application.conf for accessing the external database where the table is already available(I believe), kindly help me on this.
Below is the conf file:
application.mode=dev
%prod.application.mode=prod
db.url=jdbc:oracle:thin:#localhost:1521/orcl
db.driver=oracle.jdbc.OracleDriver
db.user=****
db.pass=****
#%test.module.cobertura=${play.path}/modules/cobertura
%test.application.mode=dev
%test.db.url=jdbc:h2:mem:play;MODE=MYSQL;LOCK_MODE=0
%test.jpa.ddl=create
%test.mail.smtp=mock
Note: Presently I am connecting to the external Oracle database and not with the embedded H2 database.
In your application.conf set the following property to none:
jpa.ddl=none