New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failure to connect to different port with FBWrappingDataSource [JDBC333] #379
Comments
Modified by: @mrotteveelreporter: Mark Rotteveel [ avalanche1979 ] => Pavel Zotov [ tabloid ] |
Modified by: @mrotteveelAttachment: attach_1_jaybird_datasource_connect_to_remote_database.zip [ 12400 ] Attachment: attach_2_jaybird_datasource_connect_to_remote_database.zip [ 12401 ] |
Commented by: @mrotteveel It could be a bug that it tries to connect with the default port. I haven't had time to check yet. Have you tried what happens when 1) you have a Firebird running on the default port and 2) you connect with the URL that contains the non-default port: does it connect to the default port? Re deprecation of org.firebirdsql.pool.*: Re the comments in the example class (which really needs a re-write BTW, see JDBC215).: The comment in the example class refers to when JDBC 2.0 standard extension was introduced (1998), Sun expected to deprecated DriverManager in future JDBC revisions. The JDBC 2 Standard Extension API spec says: "we encourage developers to regard the DriverManager as a legacy feature of the JDBC API. Applications should use the DataSource API whenever possible.". This deprecation never happened and current JDBC specification no longer says that DriverManager should be considered a legacy API. |
Commented by: @pavel-zotov > Have you tried what happens when Yes, I've tried it just now, first connecting to remote machine (with address 192.168.0.201) and then moved JRE + class on that host and tried there to connect via specifying LOCALHOST instead of IP. RESULT: the error code differs when port = 3050 was specified. Please see new attach: class source + logs of calls for port 3050 vs 3252. > 2) you connect with the URL that contains the non-default port: does it connect to the default port? 1. I did the following: set port to default 3050, restart FB 2. Check that connection will be OK if specify this port: 3. Check the error code when in intentionally set port to wrong value (choosed 3210): C:\1Install\FIREBIRD_2_5\bin\isql localhost/3210:employee 4. Check what java class says in case when trying to connect via this 'wrong' port = 3210: java -cp . DriverExample jdbc:firebirdsql://localhost/3210:employee >localhost_3210.log 2>localhost_3210.err Content of localhost_3210.log: trying to connect to databaseURL=>jdbc:firebirdsql://localhost/3210:employee< Unable to establish a connection through the driver manager. Content of localhost_3210.err: So, there is two conclusions. ### 1 ### We got the SAME error = 335544375 in both cases: There is BIG difference in behaviour of ISQL and java class when connect using 'wrong port': ISQL attempts lead to appering in firebird.log two messages: CSMIRROR (Client) Sat Dec 14 09:43:24 2013 ### 2 ### We got error 335544721 (Unable to complete network request to host ". . .") whe trying to connect via JDBC DriverManager using CORRECT, but non-default, port = 3252. And in this case there *IS* some delay when jdbc tries to connect. But there are NO any new messages in firebird.log. HTH. |
Commented by: @pavel-zotov file jdbc_connect_-_errors_differs_for_port_3252_vs_3050.zip contains logs of stdout and sterrr in case of connecting to default and non-default ports. THEY DIFFERS! |
Modified by: @pavel-zotovAttachment: jdbc_connect_-_errors_differs_for_port_3252_vs_3050.zip [ 12402 ] |
Commented by: @mrotteveel I hadn't noticed it before, but the jdbc:firebirdsql://localhost/3210:employee you use with DriverManager is not a valid JDBC url (see http://www.firebirdsql.org/file/documentation/drivers_documentation/java/faq.html#pure-java-default ). The datasource url should be fine, but I was wondering if you have an alias for employee on localhost and not on 192.168.0.201? Re ### 1 ###: |
Commented by: @pavel-zotov It seems that the problem was in two slahes in database URL, between "firebirdsql:" and ip-address (or hostname). Compare: java -cp .;jaybird-full-2.2.4.jar DriverExample jdbc:firebirdsql://192.168.0.201/3252:employee Output:Firebird JCA-JDBC driver version 2.0 registered with driver manager. trying to connect to databaseURL=>jdbc:firebirdsql://192.168.0.201/3252:employee< org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544721. Unable to complete network request to host "192.168.0.201". ### vs ### java -cp .;jaybird-full-2.2.4.jar DriverExample jdbc:firebirdsql:192.168.0.201/3252:employee Output:Firebird JCA-JDBC driver version 2.0 registered with driver manager. trying to connect to databaseURL=>jdbc:firebirdsql:192.168.0.201/3252:employee< Connection established. PS. I see in official JDBC doc and can`t find yet are these two slashes mandatory in database URL or not. |
Commented by: @mrotteveel See my previous comment. Jaybird has two URL formats: You can't combine those two. |
Commented by: @mrotteveel In conclusion, the problem was with an incorrect JDBC url. When Jaybird parsed the URL it got hostname 192.168.0.201, no port (so defaults to port 3050) and database 3252:employee. See http://www.firebirdsql.org/file/documentation/drivers_documentation/java/faq.html#pure-java-default |
Commented by: @pavel-zotov --- quote beg --- You can't combine those two. Mark, in what place you see that I *combined* these two type of URL ? Can you please point what exactly wrong in this call: java -cp .;jaybird-full-2.2.4.jar DriverExample jdbc:firebirdsql://192.168.0.201/3252:employee -- ? |
Commented by: @mrotteveel To connect using the standard URL format to 192.168.0.201 on port 3252 you'd need to use: Note the placing of the colon (:) before port and slash (/) after, which is the reverse of what you have in your URL. The URL you are using is: jdbc:firebirdsql://192.168.0.201/3252:employee |
Commented by: @pavel-zotov Mark, thank you very much. Sorry for my carelessnes: I could see myself this mistake before. |
Commented by: @mrotteveel No problem; this isn't the first time the two url formats have caused confusion :( |
Commented by: @pavel-zotov Mark, you say above that: Does it mean that second variant ( which is "isl-like" ) will be deprecated in the future ? |
Commented by: @mrotteveel For the time being it will be supported, but its use is discouraged in favor of the standard format as that is more like the URL format of other JDBC drivers. |
Submitted by: @pavel-zotov
Attachments:
attach_1_jaybird_datasource_connect_to_remote_database.zip
jdbc_connect_-_errors_differs_for_port_3252_vs_3050.zip
attach_2_jaybird_datasource_connect_to_remote_database.zip
Originally reported by Pavel Zotov on JDBC306:
Mark,
this problem also present in JayBird 2.2.4 if we try to connect to remote database.
Scenario:
-- first test that connection OK via isql:
isql 192.168.0.201/3252:employee
Database: 192.168.0.201/3252:employee
SQL> show version;
ISQL Version: WI-V2.5.3.26722 Firebird 2.5
Server version:
Firebird/x86/Windows NT (access method), version "WI-V2.5.3.26682 Firebird 2.5"
Firebird/x86/Windows NT (remote server), version "WI-V2.5.3.26682 Firebird 2.5/tcp (CSMIRROR)/P12"
Firebird/x86/Windows NT (remote interface), version "WI-V2.5.3.26722 Firebird 2.5/tcp (csprog)/P12"
on disk structure version 11.2
-- then try to connect and get some data using FBWrappingDataSource object
-- result: OK
-- (source code and output see in attach-1)
-- then try to connect via DriverManager:
>java -cp .;jaybird-full-2.2.4.jar DriverExample
Firebird JCA-JDBC driver version 2.0 registered with driver manager.
org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544721. Unable to complete network request to host "192.168.0.201".
at org.firebirdsql.jdbc.FBDataSource.getConnection(FBDataSource.java:123)
at org.firebirdsql.jdbc.AbstractDriver.connect(AbstractDriver.java:126)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at DriverExample.main(DriverExample.java:167)
Caused by: org.firebirdsql.gds.GDSException: Unable to complete network request to host "192.168.0.201".
at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.connect(AbstractJavaGDSImpl.java:1875)
at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.internalAttachDatabase(AbstractJavaGDSImpl.java:431)
at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.iscAttachDatabase(AbstractJavaGDSImpl.java:411)
at org.firebirdsql.jca.FBManagedConnection.<init>(FBManagedConnection.java:105)
at org.firebirdsql.jca.FBManagedConnectionFactory.createManagedConnection(FBManagedConnectionFactory.java:490)
at org.firebirdsql.jca.FBStandAloneConnectionManager.allocateConnection(FBStandAloneConnectionManager.java:69)
at org.firebirdsql.jdbc.FBDataSource.getConnection(FBDataSource.java:120)
... 4 more
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.openSocket(AbstractJavaGDSImpl.java:1969)
at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.connect(AbstractJavaGDSImpl.java:1852)
... 10 more
Unable to establish a connection through the driver manager.
GDS Exception. 335544721. Unable to complete network request to host "192.168.0.201".
Error Code: 335544721
SQL State: HY000
Closing database resources and rolling back any changes we made to the database.
file DriverExample.java see in attach-2
[ Permalink | Edit | Delete | « Hide ]
Mark Rotteveel added a comment - 12/Dec/13 10:59 PM - edited
Hi Pavel, that is not the same error as this issue is about. Your exception is a refused connection on the socket level, either because you specified the wrong port, the port isn't bound to the specified IP address or the port is shielded by a firewall.
The exception this issue is about is a weird problem where an existing, established connection suddenly breaks. The error message is the same, except that it doesn't include the hostname.
PS FBWrappingDataSource should be considered deprecated and will be removed in Jaybird 3.0 (the whole org.firebirdsql.pool package will be removed).
[ Permalink | Edit | Delete | « Hide ]
Pavel Zotov added a comment - 13/Dec/13 05:19 AM
> Your exception is a refused connection on the socket level, either because you specified the wrong port,
> the port isn't bound to the specified IP address or the port is shielded by a firewall.
Mark,
port is the same (3252). I've copied URL from isql connection argument that was issued before:
public final class DataSourceExample
{
private final static String DB_URL = "192.168.0.201/3252:employee";
private final static String DEFAULT_USER = "sysdba";
private final static String DEFAULT_PASS = "masterkey";
. . .
compare with:
public class DriverExample {
private static final String URL_DEFAULT = "jdbc:firebirdsql://192.168.0.201/3252:employee";
private static final String USER_DEFAULT = "sysdba";
private static final String PASSWORD_DEFAULT = "masterkey";
. . .
No firewall on that machine.
And I can`t understand what you mean by this: "port isn't bound to the specified IP" - do you mean to analyze result of netstat -a | findstr /c:3252
- ?
Result of netstat -an on server host (192.168.0.201/3252) when connect from isql was established:
netstat -an 3 | findstr /c:3252
TCP 0.0.0.0:3252 0.0.0.0:0 LISTENING
TCP 192.168.0.201:3252 192.168.43.96:4973 ESTABLISHED
TCP 0.0.0.0:3252 0.0.0.0:0 LISTENING
TCP 192.168.0.201:3252 192.168.43.96:4973 ESTABLISHED
TCP 0.0.0.0:3252 0.0.0.0:0 LISTENING
TCP 192.168.0.201:3252 192.168.43.96:4973 ESTABLISHED
TCP 0.0.0.0:3252 0.0.0.0:0 LISTENING
TCP 192.168.0.201:3252 192.168.43.96:4973 ESTABLISHED
================
> PS FBWrappingDataSource should be considered deprecated and will be removed in Jaybird 3.0
Sounds very unexpectedly.
So what about this ( $JayBird_HOME/examples/DataSourceExample.java ):
// The DataSource facility provides an alternative to the JDBC DriverManager,
// essentially duplicating all of the driver managerТs useful functionality.
// Although, both mechanisms may be used by the same application if desired,
// JavaSoft encourages developers to regard the DriverManager as a legacy
// feature of the JDBC API.
// Applications should use the DataSource API whenever possible.
// A JDBC implementation that is accessed via the DataSource API is not
// automatically registered with the DriverManager.
// The DriverManager, Driver, and DriverPropertyInfo interfaces
// may be deprecated in the future.
- ??
The text was updated successfully, but these errors were encountered: