JB2: JDBC -> ODBC -> Informix (Connection String)
Posted in 1999
Topics: Connectivity: ODBC / JDBC / .NET, Security, Permissions & Auditing
First about me and my project: I'm working on my first project in JBuilder2. It's about querying an Informix database through JDBC-ODBC. My problem: If I make a new ODBC source in the ODBC Data Source Administrator and I specify the name of the database (and of course server) I want to connect to, I can establish a working connection without any problem: database1.setConnection( new borland.sql.dataset.ConnectionDescriptor("jdbc:odbc:ius", "name", "password", false, "sun.jdbc.odbc.JdbcOdbcDriver") ); The problem is that I should make a connection to a predefined server, but the user should be able to choose to which database on that server he wants to log in (dynamically). So, I don't specifiy a database name while setting up the ODBC source. I think my problem can be resolved by using a ConnectionString, but I never succeeded making a working connection using such a string. This is what I tried: database1.setConnection( new borland.sql.dataset.ConnectionDescriptor("jdbc:odbc:ius", "name", "password", false, "sun.jdbc.odbc.JdbcOdbcDriver", ConnectionDescriptor.arrayToProperties(new String[][] { {"DB", "myDatabase"}, })) ); What's the result I get? - if I specify a database name in the ODBC source, JDBC still creates a connection to the database specified in ODBC (and not to "myDatabase"). - if I don't specify a database name in the ODBC source, JDBC complains: "insufficient information to connect to the data source" JDBC seems to ignore my ConnectionString! Is there someone who knows a solution??
On Wed, 17 Feb 1999 09:45:47 +0100, Christophe Bamelis <christophe.bamelis@teleatlas.com> wrote: >First about me and my project: > >I'm working on my first project in JBuilder2. It's about querying an >Informix database through JDBC-ODBC. > > >My problem: > >If I make a new ODBC source in the ODBC Data Source Administrator and I >specify the name of the database (and of course >server) I want to connect to, I can establish a working connection >without any problem: > >database1.setConnection( > new borland.sql.dataset.ConnectionDescriptor("jdbc:odbc:ius", > "name", "password", false, "sun.jdbc.odbc.JdbcOdbcDriver") >); > > >The problem is that I should make a connection to a predefined server, >but the user should be able to choose to which database on >that server he wants to log in (dynamically). So, I don't specifiy a >database name while setting up the ODBC source. I think my >problem can be resolved by using a ConnectionString, but I never >succeeded making a working connection using such a string. > >This is what I tried: > >database1.setConnection( > new borland.sql.dataset.ConnectionDescriptor("jdbc:odbc:ius", > "name", "password", false, "sun.jdbc.odbc.JdbcOdbcDriver", > ConnectionDescriptor.arrayToProperties(new String[][] { > {"DB", "myDatabase"}, > })) >); > >What's the result I get? > >- if I specify a database name in the ODBC source, JDBC still creates a >connection to the database specified in ODBC (and not to >"myDatabase"). > >- if I don't specify a database name in the ODBC source, JDBC complains: >"insufficient information to connect to the data source" > >JDBC seems to ignore my ConnectionString! Is there someone who knows a >solution?? I have a question first. Why are you using the jdbc-odbc bridge? It's known to be buggy. Download the Informix Type 4 JDBC driver and use that. I know it works from inside JBuilder, because I use it (along with the Oracle & PostgreSQL Type 4 drivers). Can't help with the Borland dataset stuff. I decided to 'roll my own' using just JDK1.2 classes. Peter Wiley
What do you need to run on the DBMS server host to allow a JDBC connection? I mean, which entries on /etc/services, ~informix/etc/sqlhosts and which Informix deamons should be running on an Unix box (Infomix OnLine 7.12 on AIX 3.2.5)? TIA, Igor Peter Wiley wrote: > > I have a question first. > > Why are you using the jdbc-odbc bridge? It's known to be buggy. > Download the Informix Type 4 JDBC driver and use that. I know it works > from inside JBuilder, because I use it (along with the Oracle & > PostgreSQL Type 4 drivers). [...] > > > Peter Wiley -- (opinions stated are not necessarily those of my employer)
On Thu, 25 Feb 1999 16:58:39 +0100, "Igor A. Walter" <iawalter@my-dejanews.com> wrote: >What do you need to run on the DBMS server host to allow a JDBC connection? Nothing :-) >I mean, which entries on /etc/services, ~informix/etc/sqlhosts and which >Informix deamons should be running on an Unix box (Infomix OnLine 7.12 on >AIX 3.2.5)? Assuming you're running the Informix network listener already on a known port, you need do nothing else. Otherwise, you need a port defined in /etc/services and a listener on that port. See the release notes for your version or do a search of this n/g, but it's pretty trivial. The URL to connect to your database is: con =DriverManager.getConnection ("jdbc:informix-sqli://192.0.0.1:9999/databasename:informixserver=servername;user=username;password=password"); where: 192.0.0.1 is the server IP address or name 9999 is the port number that the Informix listener is using databasename is the database you want to connect to (Hint: if you want to connect to a SE 7.x database that's not in your home directory, use the FULL pathname or else it don't find the database. Been there...) informixserver is what your listener is called in your SQLHOSTS file username & password are self-explanatory. HTH. Java is nice to use; I just d/loaded the latest Informix driver. Now to see what bugs they've fixed & what extra goodies there are. JDBC 2 scrollable resultsets is all I really need. Peter Wiley
On Tue, 02 Mar 1999 04:02:53 GMT, peterwiley@hotmail.com (Peter Wiley) wrote: [snip] >Java is nice to use; I just d/loaded the latest Informix driver. Now >to see what bugs they've fixed & what extra goodies there are. JDBC 2 >scrollable resultsets is all I really need. And they're not there. The driver is compliant to JDBC 1.22, not JDBC 2.0. Peter Wiley