I am trying to create a connection using Java DB (Embedded), but I keep getting the error shown in the image below:
If it helps my Java DB Installation path is: C:\Program Files (x86)\glassfish-3.1.2.2\javadb and my database location is: C:\Users\MyPC\.netbeans-derby
I have tried specifying the file paths, I have watched YouTube tutorials and tried a few examples from Oracle and other sites, none of which help.
The properties (if it helps) for this database are:
I noticed that the driver class is ClientDriver, is it posible this could be playing a role in the problem?
How can I get the Java DB (Embedded) connection to work (or simply correct the problem)?
The root directory doesn't load, find the location on the Database,
eg C:\Users\xxx.netbeans-derby\dataBaseName
copy it and paste it as the database Java DB(Embedded) name. Your new JDBC URL: is now jdbc:derby:C:\Users\xxx.netbeans-derby\dataBaseName
Test the connection and the path should connect.
I think this is a bug in 8.1 and needs to be addressed, but this will work around it.
Related
So I generated a new Spring boot application using jhipster. Upon navigating to the H2 console, the following information is shown.
I am able to login, and I can verify tables exist.
Next, I copy the link, jdbc:h2:file:./target/h2db/db/ikdoemee and try to connect to the H2 database using IntelliJ which shows successful.
However, the IntelliJ database view isn't showing any tables.
I tried adding the following parameters to my JDBC url, but no tables show up.
jdbc:h2:file:./target/h2db/db/ikdoemee;AUTO_SERVER=TRUE;DB_CLOSE_DELAY=-1 ;DATABASE_TO_UPPER=false
Why am I unable to get my tables visible in IntelliJ?
My .h2.server.properties is
#H2 Server Properties
0=JHipster H2 (Disk)|org.h2.Driver|jdbc\:h2\:file\:./target/h2db/db/ikdoemee|ikdoemee
webAllowOthers=true
webPort=8082
webSSL=false
EDIT: My target folder:
You need to activate h2 "Automatic Mixed Mode" by changing the spring.datasource.url of the application-dev.yml file.
example URL: jdbc:h2:./target/h2db/db/'PROJECTNAME';AUTO_SERVER=TRUE
The URL for the connection to the h2 database should look like that:
jdbc:h2:/home/'USERNAME'/IdeaProjects/'PROJECT'/target/h2db/db/'PROJECTNAME';AUTO_SERVER=TRUE
if that doesn't work try also to delete the target folder and refresh the h2 connection
To resolve this issue I installed Buddy JPA plugin.
It created profile automatically and I compared it with mine.
the difference was in parameter DB_CLOSE_ON_EXIT=FALSE
I tried it with manually created profile and it works as well.
The result link is:
jdbc:h2:file:./work/h2db;DB_CLOSE_ON_EXIT=FALSE
The only solution that worked for me at the moment is to put the direct path to the file in Path field without extension.
After that I could see my tables in IDEA.
click to preview settings
Note:
Don't forget to also add parameter AUTO_SERVER=TRUE to datasource.url, as pointed out by #Unknown_Energy.
My apps versions:
Idea 2018.3.5 UE
h2 1.4.197
h2 base name: demo.mv.db
this bug is related to these issues:
Data Source detection
Intellij IDEA and H2 DB file recognition problem
When running the application, the log will show something like
n.w.config.DatabaseConfiguration 1: H2 database is available on port 18080.
Then change Connection Type to Remote and port to the port just showed,
append the db file location to the url (with out extension) just like ./build/h2db/db/projectname, User will be the ProjectName.
The final url will like jdbc:h2:tcp://localhost:18080/./build/h2db/db/projectname
This worked for me, I'm not a English native speaker, sorry for my poor English.
I'm currently working on a project that requires me to connect our Java Project to a SQLite database with jdbc.
We've been using a database.db file located in the main/resources folder for a while without any issues. Now we're trying to switch to a hosted database, because this project is intended for multiple users and so far, we've had to include the database.db file with every git commit.
So, the most obvious first choice would be to instead of using the local resource, link to a hosted file. We have hosted our database.db file on a public server (yeah, yeah, but data security is not relevant for this project) and changed the resource to the hosted file, but it doesn't seem to work and returns "Resource not found" errors. We can't seem to get the syntax right. Here's what we have:
[...]
public Connection connectOrCreateDatabase(String databaseName) throws ClassNotFoundException, SQLException{
Class.forName("org.sqlite.JDBC");
connection = DriverManager.getConnection("jdbc:mysql:http://server.com/"+databaseName+".db");
[...]
Is there any way to get this to work?
Or is http just not supported at all?
Thanks in advance!
No, you can't use it over HTTP and pretend it's on the file system.
Why? You can read the db file over HTTP, but you can't write to it, making inserts and updates impossible.
You need to set it up in server mode and connect to it like a "real" database.
I am total novice in this topic. In general, my friend created derby database in netbeans. All databases were stored in directory:
home/.netbeans-derby
He ziped the folder with database he created, and sent to me. I entered unziped database folder to my directory (screen with it:https://dl.dropboxusercontent.com/u/108321090/DATABASE_FOLDERS.png) :
C:\Users\Fisher\.netbeans-derby
Netbeans finds this database and shows it in the tree under Java DB. When use "Connect" on this database I get error (screen with it: https://dl.dropboxusercontent.com/u/108321090/DB_ERROR.png):
Unable to connect. Cannot estabilish a connection to jdbc:derby//localhost:1527/mydatabase using org.apache.derby.jdbc.ClientDriver (DERBY SQL error: SQLCODE -1, SQLSTATE: XJ040, SQLERRMC: Starting database 'mydatabase' failed. Details are containing exception.::SQLSTATE: XSAI2. Demanded conglomeration (16) doesnt exist.).
And also I can provide you with log txt from my folder which is rly long so: https://dl.dropboxusercontent.com/u/108321090/derby.log
Please tell me is there any easy way to connect to that database or is there any EASY way to export base if it was done in wrong way? Please help me.
I followed the instructions in this blog to create a basic embedded database application.However, although checking the steps over and over and searching for the problem on the web , I'm still getting the exception : Table view blabla does not exists. Table seems to exists when I expand my driver's app schema. Netbeans version is 7.3.
The most common reason for a table-does-not-exist error with Derby is confusion over the location of the database. The database that you are accessing via Netbeans is probably different than the database that your application is accessing.
The location of your database is controlled by the JDBC connection URL, so if you provide some details about your JDBC connection URL, that might help others to help you.
This is in continuation to my previous question
I'm trying to embed a derby database in my web application. I'm able to embed it, though I am facing glitches. Here's the snapshot of my project structure.
I wonder why class.forName("org.apache.derby.jdbc.EmbededDriver") is throwing exception?
java.lang.ClassNotFoundException: org.apache.derby.jdbc.EmbededDriver
To overcome this, I have used
DriverManager.registerDriver(new org.apache.derby.jdbc.EmbeddedDriver());
Which works well. Why is it so? Also, Where would it create database if coded like this. I cannot spot the database.
connection = DriverManager.getConnection("jdbc:derby:MyDbTest;create=true");
I checked in tomcat webapps and eclipse workspace, I didn't find database.
If given this way, I can spot it.
connection = DriverManager.getConnection("jdbc:derby:E:/MyDbTest;create=true");
class.forName("org.apache.derby.jdbc.EmbededDriver")
Threw an exception because there is a 'd' missing from embedded.
See here for information about specifying the location of databases on the file system.
connecting to a file-based derby database