JDBC Connection
Posted in 2008
Topics: Connectivity: ODBC / JDBC / .NET, Networking & sqlhosts Configuration, Java & JDBC Development
I'm trying to connect to an Informix DB V7, using the jdbc driver. The connection string I'n using is; jdbc:informix-sqli://<HOST>:<PORT>/<DB>:INFORMIXSERVER=<SERVER_NAME> I'm not sure the info I'm being given is correct. I can ping the host. Where can I see what the DB and SERVER_NAME are ? What about sqlhosts? Does a protocol type of sesoctcp make a difference?
CHRIS JENKINS wrote:
> I'm trying to connect to an Informix DB V7, using the jdbc driver.
> The connection string I'n using is;
>
> jdbc:informix-sqli://<HOST>:<PORT>/<DB>:INFORMIXSERVER=<SERVER_NAME>
>
> I'm not sure the info I'm being given is correct.
> I can ping the host.
> Where can I see what the DB and SERVER_NAME are ?
> What about sqlhosts?
> Does a protocol type of sesoctcp make a difference?
>
>
sesoctcp implies that you're connecting to Standard Engine. Try onsoctcp.
Server name should be listed in your onconfig (DBSERVERNAME,
DBSERVERALIASES) and sqlhosts files. To see that database name, you'd
have to connect to the server with dbaccess and look in there for db names.
--
This message has been scanned for viruses and
dangerous content by OpenProtect(http://www.openprotect.com), and is
believed to be clean.
I don't know how to specify the protocol, for the jdbc connector? Could you send an example of the onconfig and sqlhosts? Is the protocol "fixed" by the entries in the files you mentioned?
Chris,
Please review the example below, note that in Java you always
connect to the Informix database using tcp/ip.
[informix@serv10 informix]$ grep servtst1_tcp $INFORMIXDIR/etc/sqlhosts
servtst1_tcp onsoctcp inf10-dp.corp.root.gov.mt
sqldtst1_tcp
[informix@ serv10 informix]$ onstat -c | grep servtst1_tcp
DBSERVERALIASES servtst1_tcp # List of alternate dbservernames
[informix@ serv10 informix]$ grep sqldtst1_tcp /etc/servicessqldtst1_tcp 9030/tcp
[informix@ serv10 informix]$
In your java code :
public static void openConnection() {
String url;
url = "jdbc:informix-sqli://" + hostname + ":" + dbport + "/"
+ dbname + ":informixserver=" + infxserver;
if (LOG.isTraceEnabled()) {
LOG.trace("URL: " + url);
} // if
try {
java.sql.DriverManager.registerDriver(
new
com.informix.jdbc.IfxDriver());
if (getConnection() == null) {
setConnection(java.sql.DriverManager.getConnection(
url, userName,
userPass));
connection.setAutoCommit(false);
} // if
} catch (java.sql.SQLException e) {
if (LOG.isErrorEnabled()) {
LOG.error(StackTraceUtil.getStackTrace(e));
}
} // catch
}
Hostname is the DNS of the database server (serv10 in the example above)
Dbport is the port number of the Informix server (9030 in the example
above)
Dbname is the database name (can be any valid db in that Informix
instance) Infxserver is the Informix server (servtst1_tcp in the example
above)
Hope this clarifies the matter.
Regards,
Kenneth Penza
Systems Engineer
Systems and Database Services
Service Management Department
Malta Information Technology & Training Services Ltd
Please read our Legal Notice: http://emailpolicy.mitts.gov.mt
P
Please consider your environmental responsibility before printing this
e-mail.
END OF TEXT
-----Original Message-----
From: ids-bounces@iiug.org [mailto:ids-bounces@iiug.org] On Behalf Of
CHRIS JENKINS
Sent: 08 February 2008 11:20
To: ids@iiug.org
Subject: Re: JDBC Connection [11243]
I don't know how to specify the protocol, for the jdbc connector?
Could you send an example of the onconfig and sqlhosts?
Is the protocol "fixed" by the entries in the files you mentioned?
************************************************************************
*******
Forum Note: Use "Reply" to post a response in the discussion forum.
See you at the IIUG Informix 2008 Conference
The Power Conference for Informix Professionals
April 27 - 30, 2008 Marriott Overland Park (Kansas City), Kansas
http://www.iiug.org/conf
Registration Now Open!!
I think my issues are down to the version of Informix being V7. Any other ideas would be greatly appreciated.