This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 231526 - New database connection wizard fails (Invalid connection string format)
Summary: New database connection wizard fails (Invalid connection string format)
Status: RESOLVED INCOMPLETE
Alias: None
Product: db
Classification: Unclassified
Component: Code (show other bugs)
Version: 8.0
Hardware: All All
: P2 normal (vote)
Assignee: Jaroslav Havlin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-06-19 14:16 UTC by igor_nikiforov
Modified: 2014-07-16 19:13 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description igor_nikiforov 2013-06-19 14:16:07 UTC
Steps to reproduce:
  - Open services tab.
  - Right-click Databases node and select New Connection.
  - Choose Oracle Thin and add ojdbc6.java as driver, click Next.
  - Enter Host, User Name and Password.
  - Click Test Connection -> error is displayed: invalid connection string format.
  - Remove :/ from the end of JDBC URL
  - Click Test Connection -> tests is OK.

This issue id P2 for the following reasons:
  - it's regression, compared to 7.2 (or even 7.3, haven't checked);
  - this is OSS IDE feature testing blocker.
Comment 1 Jaroslav Havlin 2013-06-24 13:20:02 UTC
(The bug was introduced in fix for issue 229250.)
Fixed in http://hg.netbeans.org/core-main/rev/4aca65476d32, please verify.
Thank you for reporting.
Comment 2 matthias42 2013-06-24 20:03:42 UTC
(In reply to comment #1)
> (The bug was introduced in fix for issue 229250.)
> Fixed in http://hg.netbeans.org/core-main/rev/4aca65476d32, please verify.

Hey Jaroslav,

could you please outline why this fixes the problem? I think I'm not enought into oracle databases, but from the documentation I conclude, that the service name needs to be optional (this matches the problem description):

http://docs.oracle.com/cd/B25329_01/doc/appdev.102/b25320/getconn.htm

See description below "Example 3-2 Specifying the Database URL Using the XE Client Installation".

Maybe the list of drivers/jdbc urls was different before the change, but I think this was already broken before.

A connection with the described procedure would have been possible, when the URL TNS-Name template was choosen and not the service name one.

The TNS-Name looks like the minimal version of the JDBC URL syntax described in the above mentioned "Example 3-2"

Thanks Matthias
Comment 3 Jaroslav Havlin 2013-06-25 09:01:32 UTC
(In reply to comment #2)
> Could you please outline why this fixes the problem?
The sample URL for Oracle DB is prepared for the "Service ID (SID)" type of the URL, and its URL template. If the correct template is set correctly at the beginning, the sample URL is parsed successfully and changing the type of URL works as expected.

If another URL template is used initially, parsing of the sample URL fails, and changing the type doesn't help (as the individual parts of the URL are empty).

The implementation is not very robust, but if the order of JdbcUrls is stable, it works fine. I think it's better to have the same order of URL types as in the previous releases, so this simple "fix" seems fine to me.

(Matthias, I know that you already know this, but putting it here as it could be useful for someone else)


You are right that we can also consider fixing the URL templates.
Current state:

URL templates:
--------------
SID:        "jdbc:oracle:thin:@<HOST>:<PORT>:<SID>[?<ADDITIONAL>]"
Service:    "jdbc:oracle:thin:@//<HOST>:<PORT>/<SERVICE>[?<ADDITIONAL>]"
TNS Name:   "jdbc:oracle:thin:@<TNSNAME>[?<ADDITIONAL>]"

Sample URL: "jdbc:oracle:thin:@localhost:1521:XE"


> [...] from the documentation I conclude, that the service
> name needs to be optional (this matches the problem description):
http://hg.netbeans.org/core-main/rev/a4a4d39683c9

> Maybe the list of drivers/jdbc urls was different before the change, but I
> think this was already broken before.
The list hasn't changed recently.

> A connection with the described procedure would have been possible, when
> the URL TNS-Name template was choosen and not the service name one.
>
> The TNS-Name looks like the minimal version of the JDBC URL syntax described
> in the above mentioned "Example 3-2"
The problem is the second semicolon in the sample URL, that can be matched only in the SID template.

We can change the sample URL and update URL templates, but I'm afraid to change something that is working fine.

Thank you, Matthias.
Comment 4 matthias42 2013-06-25 19:41:11 UTC
(In reply to comment #3)
> (In reply to comment #2)
> > Could you please outline why this fixes the problem?
> The sample URL for Oracle DB is prepared for the "Service ID (SID)" type of the
> URL, and its URL template. If the correct template is set correctly at the
> beginning, the sample URL is parsed successfully and changing the type of URL
> works as expected.
> 
> If another URL template is used initially, parsing of the sample URL fails, and
> changing the type doesn't help (as the individual parts of the URL are empty).
> 
> The implementation is not very robust, but if the order of JdbcUrls is stable,
> it works fine. I think it's better to have the same order of URL types as in
> the previous releases, so this simple "fix" seems fine to me.

Thanks! I needed some kicking to see why this fixes the problem - you did it :-)
Comment 5 Quality Engineering 2013-06-27 02:20:10 UTC
Integrated into 'main-golden', will be available in build *201306262301* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/4aca65476d32
User: Jaroslav Havlin <jhavlin@netbeans.org>
Log: #231526: New database connection wizard fails (Invalid connection string format)
Comment 6 archenroot 2014-07-16 11:58:00 UTC
I am using NB 8.0 build 20103101706. I registered the odbc6.jar driver and trying to use "Oracle Thin (TNS Name(v10.2.0.1.0 or later))" mechanism, so following URL format should be matched:

TNS Name:   "jdbc:oracle:thin:@<TNSNAME>[?<ADDITIONAL>]

But I am receiving the exception:
Cannot establish a connection to jdbc:oracle:thin:@FORCEI.WORLD using oracle.jdbc.OracleDriver (I/O-Fehler: Invalid connection string format, a valid format is: "host:port:sid" )

So it looks to me that the URL templates are not implemented yet.
Comment 7 archenroot 2014-07-16 12:26:23 UTC
Additional info:
Still the workaround is to put the tnsnames.ora entry information directly inside the JDBC string in following way:
jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL= TCP)(HOST= hosta)(PORT= 1522))(ADDRESS=(PROTOCOL=TCP)(HOST=hostb)(PORT=1521)))(SOURCE_ROUTE=yes)(CONNECT_DATA=(SERVICE_NAME=database)))

Note:
I am in Oracle RAC environment with Oracle Gateway in place.
Comment 8 matthias42 2014-07-16 19:13:37 UTC
You don't specify the driver version - I used my google'foo and got this:

http://stackoverflow.com/questions/23010218/using-tns-alias-with-ojdbc-12-1

Short summary: the 12.1 version is broken, if the tns alias contains dot characters. In the question the author compares tns aliases with dots and without dots used on version 12.1 and 11.2. While 11.2 always connects, 12.1 fails in the "dot"-case.

Please leave this bug closed and open a new bug if you can reproduce the problem with the older version of the driver.