I have a project using derby and JPA. I can connect to the database fine within my application. I would like to connect to the embedded database with SQL Developer so I can easily browse/query the data in the database.
Here is the derby dependency I'm using:
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.7.1.1</version>
</dependency>
Here is the the connection info I'm using for JPA:
<property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver"/>
<property name="javax.persistence.jdbc.url" value="jdbc:derby:fs-hash-database;create=true"/>
Using SQL Developer 3.2.09 I tried to add the driver in Tools > Preferences > Database > Third Party JDBC Drivers with the following entry:
C:\Users\axiopisty\.m2\repository\org\apache\derby\derby\10.7.1.1\derby-10.7.1.1.jar
But when I try to create a new connection, SQL Developer still only shows me the tabs for Oracle and Access. I can't get the JDBC tab for the 3rd party driver.
I think the problem is that the jar that I am adding as the 3rd party driver is the entire derby jar, not just the driver. Yet the driver is contained in the jar.
Does anyone know how to configure SQL Developer to use the org.apache.derby.jdbc.EmbeddedDriver contained within derby-10.7.1.1.jar?
SQL Developer does not support Apache Derby. It only supports a very limited (and fixed) set of DBMS as documented on the WebSite:
Oracle (obviously)
MySQL (obviously)
SQL Server
DB2
MS Access
Sybase
Teradata
(All third party DBMS are listed as "read-only" on the website - whatever that means)
You will need a "real" general purpose JDBC client to use it against Derby like Squirrel, DbVisualizer or SQL Workbench/J.
Oracle SQL Developer can be manually configured to work with Derby using the drivers that come with the JDK as of Java 8.
Step 1: In Oracle SQL Developer, include Derby related libraries.
Oracle SQL Developer -> Tools -> Preferences -> Databases -> Third Party JDBC Drivers. I simply [Add Entry...] all libraries under C:\Program Files\Java\jdk1.8.0_92\db\lib
Step 2: Manually edit connections.xml
Edit C:\Users\USERNAME\AppData\Roaming\SQL Developer\system4.1.2.20.64\o.jdeveloper.db.connection.12.2.1.0.42.151001.541\connections.xml
In this example I am using embedded Derby driver.
<Reference name="DerbyConn" className="oracle.jdeveloper.db.adapter.DatabaseProvider" xmlns="">
<Factory className="oracle.jdevimpl.db.adapter.DatabaseProviderFactory1212"/>
<RefAddresses>
<StringRefAddr addrType="OracleConnectionType">
<Contents>BASIC</Contents>
</StringRefAddr>
<StringRefAddr addrType="RaptorConnectionType">
<Contents>Microsoft SQL Server</Contents>
</StringRefAddr>
<StringRefAddr addrType="customUrl">
<Contents>jdbc:derby:firstdb;create=true</Contents>
</StringRefAddr>
<StringRefAddr addrType="driver">
<Contents>org.apache.derby.jdbc.EmbeddedDriver</Contents>
</StringRefAddr>
<StringRefAddr addrType="subtype">
<Contents>SQLServer</Contents>
</StringRefAddr>
<StringRefAddr addrType="ConnName">
<Contents>DerbyDB</Contents>
</StringRefAddr>
</RefAddresses>
Note:
1. The XML setting can be as plain as shown above.
2. customUrl is jdbc:derby:firstdb;create=true. This will initialize firstdb schema in C:\sqldeveloper\bin\firstdb. You can use jdbc:derby:D:\\Project\\derbydb\\firstdb to initialize schema to an absolute location.
I was able to get this to work on sql developer 4.0.2.15 using the network driver by adding the driver files to the classpath and then editing the connections.xml file in the directory AppData\Roaming\SQL Developer\system4.0.2.15.21\o.jdeveloper.db.connection.12.1.3.2.41.140418.1111
I did this by copying an sql server connection but it seems to work happily thinking it is an sql server database.
I added the following to the file :
<Reference name="DATABASENAME" className="oracle.jdeveloper.db.adapter.DatabaseProvider" xmlns=""\>
<Factory className="oracle.jdevimpl.db.adapter.DatabaseProviderFactory1212"/>
<RefAddresses>
<StringRefAddr addrType="port">
<Contents>1527/DATABASENAME</Contents>
</StringRefAddr>
<StringRefAddr addrType="user">
<Contents>USERNAME</Contents>
</StringRefAddr>
<StringRefAddr addrType="NoPasswordConnection">
<Contents>TRUE</Contents>
</StringRefAddr>
<StringRefAddr addrType="subtype">
<Contents>SQLServer</Contents>
</StringRefAddr>
<StringRefAddr addrType="RaptorConnectionType">
<Contents>Microsoft SQL Server</Contents>
</StringRefAddr>
<StringRefAddr addrType="ConnName">
<Contents>DATABASENAME</Contents>
</StringRefAddr>
<StringRefAddr addrType="hostname">
<Contents>HOSTNAME</Contents>
</StringRefAddr>
<StringRefAddr addrType="customUrl">
<Contents>JDBCURL</Contents>
</StringRefAddr>
<StringRefAddr addrType="SavePassword">
<Contents>false</Contents>
</StringRefAddr>
<StringRefAddr addrType="driver">
<Contents>org.apache.derby.jdbc.ClientDriver</Contents>
</StringRefAddr>
</RefAddresses>
</Reference>
You will have to configure it with the appropriate values for DATABASENAME, USERNAME, HOSTNAME and JDBCURL for your database.
I hope this helps
After many "bad URL format" and then some "null pointer exceptions" I finally succeeded to get this connection working! In my context not to an embedded DERBY Database, but to Derby launched as a network server. Here is the checklist:
Using SQL developer version 20.x (earlier may do - not checked) with a JDK 8 (above 171 is required by SQL developer). The later contains javaDB that is historically the Apache DERBY 10 database.
DERBY is started and listens to port 1527 (its default). Permissions must indeed allow localhost and/or remote connections according to your context. I strongly advise you to have your database ready, and then check connectivity with e.g. the native Derby command line tool 'ij'. For instance, at the ij prompt:
ij> connect 'jdbc:derby://localhost:1527/MyDB;user=MYUSER;password=abcd';
ensure you add the Derby JDBC driver to SQL Developer > Tools > Preferences > Database > Third Party JDBC Drivers. Browse and add
yourJDKpath\db\lib\derbyclient.jar; this single jar is sufficient.
Create a new connection, just for having the entry created in the connection config file that we will have to manually edit. Ensure you give it the name you want, with the proper user and password. Fill-in any data for the other fields and save your connection. It can't work yet.
Exit SQL developer and edit manually the connection meta data. In recent SQL developer versions, this file is in JSON, previous versions are XML, the attribute names are identical in both cases. The path is like:
C:\Users\YourNAME\AppData\Roaming\SQL Developer\system20.2.0.175.1842\o.jdeveloper.db.connection\connections.json
Open the file and identify the connection you just created. Edit it to get something like:
{
"info": {
"role": "",
"SavePassword": "true",
"OracleConnectionType": "BASIC",
"RaptorConnectionType": "Microsoft SQL Server",
"customUrl": "jdbc:derby://localhost:1527/MyDB",
"NoPasswordConnection": "TRUE",
"password": "123456789PLVEC4wxu80ijhx5ALU4ZpRgo123456789=",
"hostname": "localhost",
"port": "1527",
"subtype": "SQLServer",
"ConnName": "DerbyDB",
"driver": "org.apache.derby.jdbc.ClientDriver",
"IS_PROXY": "false",
"OS_AUTHENTICATION": "false",
"KERBEROS_AUTHENTICATION": "false",
"user": "MYUSER"
},
"name": "local DERBY",
"type": "jdbc"
}
Yes, you may have noted the references to "Microsoft SQL Server" as RaptorConnectionType and "SQLServer" as subtype. This is the magic trick. Of course, the client driver classpath is critical too, which is "org.apache.derby.jdbc.ClientDriver" for the Derby network mode client, as is the connectionUrl.
Launch SQL Developer and open the connection that will appear under "SQLServer Connections"
Related
I download oracle instant client 12.2.0.1.0, I try to use sql loader to load csv data to the database. I can successfully load using following:
sqlLdr.exe userid=user/password#//192.9.200.228:1521/oracle ERRORS=4000 control=D:\temp\csma\xx_20190225.ctl log=D:\temp\csma\xx.log
However my production would only allow secured connection only (use tcps), can I use tcps by EZConnect? If not how can I connect using tcps using just the instant client (not full client)?
Instant Client based applications can connect using a Net Service Name from a tnsnames.ora file. The Instant Client installation instructions (eg. the instructions for Linux x64) tell you where to put the Oracle Net configuration files. Create the default location, put the files there, and update the connect string in your application.
With Oracle 19c, the Easy Connect syntax was extended to be 'Easy Connect Plus' so you specify things like the wallet location in-line, see the Understanding the Easy Connect Naming Method in the Oracle Net 19c documentation. No Instant Client 19c has been released yet.
I have a database Connection established in odbcad and Microsoft Access (aswell as working in Excel) via ODBC and want to also get it working in Oracle SQL developer.
It is a Windows SQL Server as far as i know and I have tried several Settings, of which None works. I have also installed Driver for ODBC. I would like to Import Settings into SQL developer as applied in MS Access, is there any possibility?
No, SQL Developer is a Java application and uses a JDBC driver.
But if you look at the odbc properties for your connection, those should largely translate to what you need to define a basic connection.
Oracle:
Server name or IP address of the DB, port # for the listener, and the name of the SID or Service, plus a valid username and password is all you need to connect to Oracle.
What error do you get when you try to connect?
Show us what you're trying.
Update:
You're trying to connect to SQL Server but you're getting"
Native SSPI library not loaded
You're trying to use OS Authentication for your connection. For this to work with the jTDS driver, you need to copy a DLL file named ntlmauth.dll (which is for NT authentication) under the jtds-x.x.x-dist\x86\SSO\ or jtds-x.x.x-dist\x64\SSO\, to any directories in the PATH environment.
Please update your question such that's it's clear you're connecting to SQL Server and share the error message so others can find it.
I imagine this question is a duplicate of many previous iterations of the same challenge.
Is it possible to create a connection to OBIEE from Oracle SQL Developer?
I know it is possible to create an ODBC connection to the Oracle BI server within the Windows ODBC Data Source Administrator, and that other ODBC client tools can use that ODBC connection to run SQL against the BI server, but I don't see any way for SQL Developer to use that ODBC connection.
I'm on OBIEE 12.2.1.4 and SQL Developer 17.3.0.271.
UPDATE
Based on Robin Moffatt's article at https://rmoff.net/2016/03/28/connecting-to-obiee-via-jdbc-with-jisql/, I used jisql (https://www.xigole.com/software/jisql/jisql.jsp) to set up a connection to OBIEE using the JDBC driver that ships with the OBIEE client -- bijdbc.jar, which is located at $ORACLE_HOME/bi/bifoundation/jdbc/.
Following is a screenshot showing how jisql is able to successfully connect to my OBIEE server via the bijdbc.jar driver and run an example SQL statement; the Oracle-specific connection details are outlined in red:
Screenshot 1: OBIEE JDBC connection test using jisql
My next step was to try to implement this same successful JDBC connection in SQL Developer. To that end, I added bijdbc.jar to SQL Developer's third-party JDBC drivers:
Screenshot 2: bijdbc.jar added to SQL Developer third-party JDBC drivers
After adding the JDBC driver, I did not see a new tab in SQL Developer's connection dialog. (By comparison, in the past, when I have added other third-party JDBC drivers, such as the jTDS and MySQL drivers also seen in screenshot 2, new tabs had become available.)
Since there was not a new tab in SQL Developer's connection dialog, I tried setting the Oracle tab's connection type to Advanced and inserting the JDBC connection string as the Custom JDBC URL. Testing that connection leads to a "String index out of range: -1", as seen in this screenshot:
Screenshot 3: Error using custom JDBC URL in SQL Developer
Since that same JDBC connection string works in jisql, I suspect that either I'm doing something wrong, or SQL Developer does not support connecting to OBIEE via that bijdbc driver.
Ok, fair enough. Have a look at what Andrew did to make the ODBC drivers usable in Excel - it's basically down to manipulating things in Windows:
https://www.rittmanmead.com/blog/2017/02/working-with-obiee-data-in-excel-using-odbc/
Just adding a final answer here in case anyone stumbles upon this page asking the same question:
No, SQL Developer does not currently support connecting to an OBIEE server, although other tools can be used to connect to the server using either ODBC or JDBC.
I have an application which is using config file to connect to mssql server and odbc is created and used in the config file.
This is the line in my config file to connect to database.
<add key="ConnectionString" value="Data Source=<DSN Name>;Initial Catalog=<DAtabase Name>;Integrated Security=True"></add>
Now we are testing in Oracle,
but the above format is not connecting and I had tried many other permutations of connection string like below but so far no luck
This is same like Windows string
<add key="ConnectionString" value="Data Source=<DSN Name>;Integrated Security=True"></add>
Included my Database Name with DSN
<add key="ConnectionString" value="Data Source=<DSN Name>;Initial Catalog=<DAtabase Name>;Integrated Security=True"></add>
Included Driver and SID here
<add key="ConnectionString" value= Driver=<{Oracle in OraClient11g_home1}>;Server=serverSID;Uid=<myUsername>;password=<password>
></add>
The error I am receiving
Database setup cannot find the database mentioned in the config file
None of them are working wats the correct connection string for Oracle ?
Try DBQ= instead of Server= and PWD= instead of password=.
Attribute Server is used for the Microsoft ODBC Driver (see Connection String Format and Attributes). In Oracle the attribute is DBQ (see Using the Oracle ODBC Driver).
Now I have some weird problem:
our DBA blocked my OS user from connecting to the DEV database for some reason
So I was not able to connect with TOAD
but I was able to connect with SQL Developer
also I wasn't able to start my Liferay server while connecting to the DEV database, with a message: user not allowed to login to the database (or something like this)
I made some investigation to tell why is SQL Developer connecting while TOAD is not. So I came out with a fact that TOAD uses the installed SQL*Net client while SQL Developer uses a standalone thin jdbc client.
So I thought this might be the reason somehow (not sure why, but may be the installed SQL*Net client reveals the OS user while thin client doesn't)
Now my question is: why is Liferay behaving the same way as TOAD though -according to my knowledge- it shouldn't as it is connected using datasource configured in the tomcat context.xml file?
Also if someone has a good scientific explanation about TOAD vs SQL developer, it's appreciated (I think I can track the sent request using wire shark, but no time actually)
I am using Liferay 6.1 , Liferay Studio and oracle 11g database
update :
I checked the connection of Liferay tomcat and found it :
type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:#.....
The reason why you can connect with SQLDeveloper and not with Liferay may be that your SQLDeveloper uses a more recent version of the JDBC thin driver (ojdbc6.jar or ojdbc7.jar). A solution would be to replace the one if Liferay with the one from SQLDeveloper. It would be just a matter of replacing the jar and restarting the tomcat server.