How to use JDBC to connect informix database
Dear all,
I want my client application to connect informix database by using JDBC. The JDBC driver has been installed successfully in the client computer (Win2000). The informix 5.0 resides the a Unix server named "dbserver". The following is my java program.
========================
import java.sql.*;
import java.awt.event.*;
public class Application1 {
public static void main(String[] args) {
Connection conn;
try
Class.forName("com.informix.jdbc.IfxDriver");
catch (Exception e)
System.out.println("Error "+e.getmessage());
e.printStackTrace();
return;
System.out.println("It is ok");
try
conn = DriverManager.getConnection("jdbc:informix-sqli://dbserver:1526:INFORMIXSERVER=dbserver;username=test;password=******");
catch (SQLException e)
System.out.println("ERROR ."+e.getMessage());
e.printStackTrace();
return;
System.out.println("All is fine");
===========================
However, the error appears mentioning "Attempt to connect to database server (dbserver) failed." I don't know what the problem is because my informix database server is exactly "dbserver".
Kindly need help from you guys. Thanks in advance.
Kevin
Hi,
Plz try this (instead of 'username' use 'user') ...
DriverManager.getConnection("jdbc:informix-sqli://dbserer:1526:INFORMIXSERVER=dbserver;user=test;password=*****");
or this (pass the username and password as params)....
DriverManager.getConnection( "jdbc:informix-sqli://dbserer:1526:INFORMIXSERVER=dbserver" , "test" , "*****" );
Hope this helps
ssa.
>
I want my client application to connect informix
database by using JDBC. The JDBC driver has been
installed successfully in the client computer
(Win2000). The informix 5.0 resides the a Unix server
named "dbserver". The following is my java program.
========================
import java.sql.*;
import java.awt.event.*;
public class Application1 {
public static void main(String[] args) {
Connection conn;
try
Class.forName("com.informix.jdbc.IfxDriver");
catch (Exception e)
System.out.println("Error "+e.getmessage());
e.printStackTrace();
return;
System.out.println("It is ok");
try
conn =
onn =
DriverManager.getConnection("jdbc:informix-sqli://dbser
er:1526:INFORMIXSERVER=dbserver;username=test;password=
catch (SQLException e)
System.out.println("ERROR ."+e.getMessage());
e.printStackTrace();
return;
System.out.println("All is fine");
===========================
However, the error appears mentioning "Attempt to
connect to database server (dbserver) failed." I don't
know what the problem is because my informix database
server is exactly "dbserver".
Kindly need help from you guys. Thanks in advance.
Kevin
Similar Messages
-
How to use JDBC to connect Tomcat with database server?(Urgent!)
I try to deploy the tomcat and make it connect with databaser server.
I am using mysql connector J 3.0. I added the CLASSPATH of mysql-connector-java-3.0.7-stable-bin.jar in the tomcat.sh .
I also add the web application in server.xml.
When I start tomcat, I can see using Classpath including mysql-connector-java-3.0.7-stable-bin.jar .
But when i browse my jsp including the jdbc, wait for a while, I get a message as following: Timeout on server localhost. My web server and database server is same computer.
Could you tell me what's wrong?Did you check to see that the MySQL database was indeed up and running, and accepting connections when you started Tomcat? Did you make sure that your firewall permits connections to the database?
Timeout errors generally occur when you send a request to a server and the server does nothing with it - i.e., it doesn't respond to it in any way. Most firewalls are configured this way. If I telnet to your machine and I get "connection refused", I know your machine exists and I can try hacking into it. If I telnet and get nothing at all, then I will either assume either there's no actual machine at that address or it's unresponsive. -
How to use datasources to connect to database ?
I have the following Problem
I have two identical databases, one is the development database, the other one the production database.
Now I need to find a way, how I can deploy an bc4j-application in local mode that way, that if the application is deployed to server 1 it connects to database 1 and if deployed to server 2 it connects to database 2.
JDBC connection strings do not work as the connection is deployed with the application. So the application always connects to the same database.
I thought datasources might be the solution. So I tried to define a datasource MyDS in the data-sources.xml file and specified it in the Configuration Wizard as the connection to use.
But unfortunately this does not work and i do not know why:
If I try to connect using the tester and using this datasource I get the following exception:
Level #3: javax.naming.noInitialContextException
Can anyone help me, what this means? How can I get around this using the BC4J Framework? Is there any "HowTo" Document which describes using datasources with BC4J?Frank,
I've sorted this stuff out to some extent. Have a look at this thread:
re:? How: multiple myAppWar.ear to use OC4J's data-sources.xml pooling?
If this isn't all you need, then search on data-source.xml
and read other threads also I may have posted helps on
other threads so if you search on data-source.xml and my handle (curt504) it brings up all the threads that I posted to.
Not to say I've solved all your problems, but I solved mine anyway. :)
Good luck,
curt -
How to use jdbc to connect oracle
I want use jdbc direct to connect oracle database,and I
want to use sun Company or oracle Company driver. how can I get driver and how do I write connection string?
Deeply to wait your reply,thank you!The correct format would be jdbc:oracle:thin@server:port:sidTry "jdbc:oracle:thin:@192.168.84.20:1521:ORDB","ysys","fareast"and see what happens.
Note that you two formats for the DriverManager.getConnection() method; if DriverManager.getConnection(db_url, username, password) doesn't work, try the other call with a fully-qualified database url:DriverManager.getConnection("jdbc:oracle:thin:ysys/[email protected]:1521:ORDB")The SID is the server ID that was given to the instance when the database was installed; default is ORCL, but may have been changed. Port default is 1521, but again, this may be different for your system. -
How to use JDBC to connect Oracle databse
Hi
I try to connect the oracle databse by using JDBC. But I not sure whether is it correct or not because I learnt from the documentation provided by WWW.JAVA.SUN.
I have create a ODBC DSN file call TKS username/password : tem/manager
then I download the source code and enhance a bit as following :
import java.sql.*;
public class CreateCoffees
public static void main(String args[])
String url = "jdbc:oracle:thin:tem/manager@(
description=(address_list=(
address=(protocol=tcp)
(host=192.9.200.8)(port=1521)))(source_route=yes)
(connect_data=(sid=tks)))";
Connection con;
String createString;
createString = "create table COFFEES " +
"(COF_NAME VARCHAR(32), " +
"SUP_ID INTEGER, " +
"PRICE FLOAT, " +
"SALES INTEGER, " +
"TOTAL INTEGER)";
Statement stmt;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
catch(java.lang.ClassNotFoundException e)
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
try {
con = DriverManager.getConnection(url, "tem", "manager");
stmt = con.createStatement();
stmt.executeUpdate(createString);
stmt.close();
con.close();
catch(SQLException ex)
{ System.err.println("SQLException: " + ex.getMessage());
After that I saved the file as CreateCoffees.java and compiled it
D:\KLTAY\JAVA>javac CreateCoffees.java
CreateCoffees.java:6: unclosed string literal
String url = "jdbc:oracle:thin:tem/manager@(
^
CreateCoffees.java:10: unclosed string literal
(connect_data=(sid=tks)))";
^
CreateCoffees.java:30: cannot resolve symbol
symbol : variable con
location: class CreateCoffees
con = DriverManager.getConnection(url, "tem", "manager");
^
CreateCoffees.java:31: cannot resolve symbol
symbol : variable con
location: class CreateCoffees
stmt = con.createStatement();
^
CreateCoffees.java:34: cannot resolve symbol
symbol : variable con
location: class CreateCoffees
con.close();
^
5 errors
Please give some advise.Thanks
best regards,
TayString url = "jdbc:oracle:thin:tem/manager@(
description=(address_list=(
address=(protocol=tcp)
(host=192.9.200.8)(port=1521)))(source_route=yes)
(connect_data=(sid=tks)))";
After that I saved the file as CreateCoffees.java and
compiled it
D:\KLTAY\JAVA>javac CreateCoffees.java
CreateCoffees.java:6: unclosed string literal
String url = "jdbc:oracle:thin:tem/manager@(
^
CreateCoffees.java:10: unclosed string literal
(connect_data=(sid=tks)))";
^I would suggest putting all code between the quotesj(") on one line and then attempting to recompile. -
-How to use JDBC to connect the SQLServer and Oracle.
Hi,
I create a table in the WIP DB, I want to modify this table when use "PRE-START" activity in POD.
SAPME version: 5.2.3.4 SDK:2.0 DB:SQL2005 and Oracle 10.2g
SourceCode like below:
public void execute(StartHookDTO dto) throws Exception {
initServices();
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=SAPMEWIP", "sa" ,"sap12345");
conn.close();
}catch(Exception e){
e.printStackTrace();
Besides, I already setup the JDBC ClassPath in ConfigTool, but it gets somes error when executing.
the error code like below:
java.sql.SQLException: No suitable driver
Please give me some support or a example, thank you so much!
Br,
AlexYou probably want to use the WIP Datasource defined in JNDI.
-
Using JDBC to connect all database
i want to create a DB layer through which i should be able to connect to the database specified at run time.how do i understand for databases like Mysql which OS-specific Driver to load at runtime.i want to make the Db layer platform independant and it should be able to talk to multiple databases.Is there a way to know at run time which drivers are available in the system.
i want to create a DB layer through which i should be
able to connect to the database specified at run
time.Fine. JDBC, reflection and some configuration settings should get you most of the way there.
how do i understand for databases like Mysql
which OS-specific Driver to load at runtime.Each RDBMS you want to support will have to have its driver available for use in the CLASSPATH.
i want
to make the Db layer platform independant and it
should be able to talk to multiple databases.Is there
a way to know at run time which drivers are available
in the system.That will be problematic. Not all RDBMS vendors are even totally ANSI SQL compliant. DDL is normally highly vendor specific, as are triggers, stored procedures, views. et. al. So, I would forewarn you that this will be a difficult task. Are you really sure that your requirements are valid?
- Saish -
How to use JDBC to connect to oracle7.3.4 on remote host
I have written a small applet which runs fine on one host(Solaris
box)using appletviewer. In this program I am trying to connect
to oracle on another host and the program is working fine. The
same applet is not working from a web page.
can anyone help me out?
giving error like netscape.security.AppletSecurity.exception
and lot more exception
nullYou are restricted by the Java security sandbox from connecting
directly to another machine through the applet. You have to use
a JDBC driver located on the web server machine. Please make
sure you have installed this properly, as in appended a valid
JDBC .jar archive to your CLASSPATH.
Openlink Software has robust JDBC drivers that enable scrollable
(rowset driven) cursors. You may be interested in checking out
http://www.openlinksw.com for further info.
Our latest JDBC drivers are found at
ftp://ftp.openlinksw.com/pre-3.2/index.html
(scroll down to the very bottom - Windows section - don't worry,
they're platform independent!)
Best regards
BVReddy (guest) wrote:
: I have written a small applet which runs fine on one host
(Solaris
: box)using appletviewer. In this program I am trying to
connect
: to oracle on another host and the program is working fine.
The
: same applet is not working from a web page.
: can anyone help me out?
: giving error like netscape.security.AppletSecurity.exception
: and lot more exception
null -
How to connect informix database from informatica through JDBC instead of ODBC
How to connect informix database from informatica through JDBC instead of ODBC.
Hi mate,
You may get fast reply for this in informatica forums.
Thanks
http://mkashu.blogspot.com -
How to use JDBC Connection Pools in a standalone application?
Hi, there,
I have a question about how to use JDBC Connection Pools in an application. I know well about connection pool itself, but I am not quite sure how to keep the pool management object alive all the time to avoid being destroyed by garbage collection.
for example, at the website: http://www.developer.com/java/other/article.php/626291, there is a simple connection pool implementation. there are three classes:JDBCConnection, the application's gateway to the database; JDBCConnectionImpl, the real class/object to provide connection; and JDBCPool, the management class to manage connection pool composed by JDBCConnectionImpl. JDBCPool is designed by Singleton pattern to make sure only one instance. supposing there is only one client to use connection for many times, I guess it's ok because this client first needs instantiate JDBCPool and JDBCConnectionImpl and then will hold the reference to JDBCPool all the time. but how about many clients want to use this JDBCPool? supposing client1 finishes using JDBCPool and quits, then JDBCPool will be destroyed by garbage collection since there is no reference to it, also all the connections of JDBCConnectionImpl in this pool will be destroyed too. that means the next client needs recreate pool and connections! so my question is that if there is a way to keep pool management instance alive all the time to provide connection to any client at any time. I guess maybe I can set the pool management class as daemon thread to solve this problem, but I am not quite sure. besides, there is some other problems about daemon thread, for example, how to make sure there is only one daemon instance? how to quit it gracefully? because once the whole application quits, the daemon thread also quits by force. in that case, all the connections in the pool won't get chance to close.
I know there is another solution by JNDI if we develop servlet application. Tomcat provides an easy way to setup JNDI database pooling source that is available to JSP and Servlet. but how about a standalone application? I mean there is no JNDI service provider. it seems a good solution to combine Commons DBCP with JNID or Apache's Naming (http://jakarta.apache.org/commons/dbcp/index.html). but still, I don't know how to keep pool management instance alive all the time. once we create a JNDI enviroment or naming, if it will save in the memory automatically all the time? or we must implement it as a daemon thread?
any hint will be great apprieciated!
SamTo my knoledge the pool management instance stays alive as long as the pool is alive. What you have to figure out is how to keep a reference to it if you need to later access it.
-
How to use JDBC Lookup in PI 7.1 ?
Hi,
Please advise how to use JDBC lookup in message mapping PI 7.1 ? any reference link / document ?
I have followed this step below :
1. Create the external definition for the database table.
2. Use the external definition (table) in message mapping JDBC Lookup.
But the target still "Yellow colour" meanint the mapping hasnot completed yet ? why ? and when i double click the JDBC lookup
there some error message
"No suitable parameter found; define new parameter of type 'Channel' first"
Please advise.
Thank You and Best Regards
FernandHi Fernand,
JDBC Lookup can be done in PI 7.1 using below mentioned steps :
1) Create a communication channel between PI and the database to connect to database.
2) Import the table data as External Definition.
3) In message mapping where this lookup is to be used select JDBC Lookup under Conversions and map
4) Double Click on JDBC Lookup
5) Select parameter and a database table (imported as the external definition). All the elements of the table will appear in the middle column. Select and move the input parameters to the left side column and the output parameters to the right side column. Click OK.
6) Under message mapping go to signature tab and define the parameter as channel and category as JDBC Adapter Type.
7) Under Operation mapping define the parameter & associate it with parameter defined in Message Mapping.
Thanks
Amit -
Is there any documentation on how to use JDBC in ALBPM?
I'm trying to connect to a DB using DriverManager class.
1) I've defined an externalResource of type SQL Database.
2) When I execute the following code:
//externalResourceURL is the URL of the SQL Database external resource created in 1), same for user and password
con as java.sql.Connection = DriverManager.getConnection(arg1=externalResourceURL, arg2=user, arg3=password)
3) I get the following error: This driver is locked for use with embedded applications.
Is there any tutorial or documentation on how to use JDBC in ALBPM?
Thanks in advanceI don't know of any documentation off hand... but what are you trying to do? I haven't needed to to make a connection using the DriverClass....
If you aren't using dynamicSQL... you can just catalog the database, and make direct sql calls (not recommended)... but if you catalog it, then just an INSERT command works... or UPDATE... etc
logMessage "Starting insert."
INSERT INTO MYTABLE(id, name) VALUES ("2", "kevin");
logMessage "Finished insert."Check out the studio help under SQL Keywords for more info on that...
HTH
-Kevin -
How to use taglibs in JSP for Database access
Hi
Could any one please tell me how to use taglibs in JSP for Database access
with regrds
JojoThis is a sample how to connect to a MySQL database with JSTL 1.0:
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<%@ taglib uri="http://java.sun.com/jstl/sql" prefix="sql" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>JSTL MySQL</title>
<link href="styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<c:catch var="e">
<sql:setDataSource var="datasource" url="jdbc:mysql://Your_Server_Name_Here/You_Schema_Here"
user="Your_Username_Here" password="Your_Password_Here"
driver="com.mysql.jdbc.Driver"/>
<c:out value="datasource= ${datasource}, Class = ${driver.class}"/>
<br />
<br />
<sql:query var="deejays" dataSource="${datasource}">SELECT * FROM Your_Table_Name_Here</sql:query>
<table>
<%-- Get the column names for the header of the table --%>
<c:forEach var="columnName" items="${deejays.columnNames}"><th><c:out value="${columnName}"/></th></c:forEach>
<tbody>
<%-- Get the value of each column while iterating over rows --%>
<c:forEach var="row" items="${deejays.rows}">
<tr><c:forEach var="column" items="${row}">
<td><c:out value="${column.value}"/></td>
</c:forEach>
</tr>
</c:forEach>
</tbody>
</table>
</c:catch>
<br />
<br />
<c:if test="${e!=null}"><span class="error">Error</span>�
<c:out value="${e}" />
</c:if>
</body>
</html>And this thread might help you:
http://forum.java.sun.com/thread.jspa?threadID=639471&tstart=44 -
I want to use jdbc to connect MS SQL SERVER
hi,
I want to use jdbc to connect MS SQL SERVER,not the jdbc-odbc bridge.
I download the driver from MS,deploy it,but when I connect the database such as:
<%Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");%>
<%String sConnStr="jdbc:microsoft:sqlserver://computer2000:1433";%>
<%Connection conn=DriverManager.getConnection(sConnStr,"sa","123");%>
<%Statement stmt=conn.createStatement();%>
but it said
javax.servlet.ServletException: com.microsoft.jdbc.sqlserver.SQLServerDriver
java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver
how can i work out this problem
maybe my configure is wrong,please give me a successful sample configuration
thanks a lotHi,
I am not sure where you have got the following code from
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
What happens here, is Java Runtime will search for the Class named:
com.microsoft.jdbc.sqlserver.SQLServerDriver
If this Class is not in the Runtime Classpath, it will throw the Error that you have got. Kindly get the proper driver as well as ensure that the Class is available in the Runtime Classpath.
Thanks and regards,
Pazhanikanthan. P -
How do i configure DSN connection to database Programmatically
Hi to all,
Can anybody assist me as how could i configure DSN connection to database Programmatically.
Thanks in advance.
Regards
khiz_engHi DrClap,
Many thanx for your advise, i have also done with MS-Access but now i wnated to have with .csv value, how i am going to have this .I have searched the whole JDBC forum already unable to find for .csv
Please provide me and solve my problem
Thanks in advance.
khiz_eng
Maybe you are looking for
-
Closing Stock For Each Period in Inventory Infocube
Hello Guru's, Can we have closing stock of each material for entire period in Invnetory Infocube ? or through any logic or transformation routine can we create this keyfigure at infocube level ? I know that to get Closing Stock ( Opening Stock + G
-
Computer to TV Hookup Vs. Apple TV : Quality
I was thinking of purchasing an Apple TV soon but I have a few concerns about spending $300 plus cables. If I hook my computer up to my TV will it be the same or better quality that Apple TV offers? Thanks
-
CD importing and syncing problems
I imported a CD into my library but everytime I try to put the music onto my phone it says "Updating File" but stops after like a second. There's also a dotted circle next to the songs but I made sure there's sufficient space on the phone and the man
-
I am using firefox 6.0a2 on fedora 15. I am updating firefox daily. System hangs suddenly after installing addons.
-
Error 6753 when printing with airport express
Hi all- I'm trying to us my airport express to set up wireless printing from my PC laptop. Right now, I've got a netgear router and I -think- I've managed to con nect the airport express to join that network. My goal is simply to use the airport expr