Connection to Informix using dsn.::::java.net.MalformedURLException from WSAD5.0
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Deve_Reddy
Posted On:   Thursday, March 11, 2004 10:49 PM

Hi All,when i use dsn to connect informix,getting error: javax.naming.InvalidNameException: jdbc:informix-sqli://dbserver:1025/npc:INFORMIXSERVER=testdb;user=informix;password=informix [Root exception is java.net.MalformedURLException: unknown protocol: jdbc]> can any one see my connection class and advise.... thanks in advance.. regd Dev package com.npc.data; import java.sql.Connection; import java.sql.DriverManager; import javax.naming.Context; import javax.naming.InitialContext; import javax.sql.DataSource; import javax.naming.*; public class DbConnectionHandler{ public static Connecti   More>>

Hi All,when i use dsn to connect informix,getting error:

javax.naming.InvalidNameException: jdbc:informix-sqli://dbserver:1025/npc:INFORMIXSERVER=testdb;user=informix;password=informix [Root exception is java.net.MalformedURLException: unknown protocol: jdbc]>


can any one see my connection class and advise....

thanks in advance..

regd
Dev



package com.npc.data;

import java.sql.Connection;
import java.sql.DriverManager;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;
import javax.naming.*;


public class DbConnectionHandler{

public static Connection ifxCon = null; //Connection Object


public DbConnectionHandler(){
}


public static Connection getIfxConnection(){

Context ctx;
DataSource ds ;
String user = "informix";
String pwd = "informix";
String dsName = "jdbc/myjndi"; // testing dsn

String dbURL = "jdbc:informix-sqli://dbserver:1025/npc:INFORMIXSERVER=testdb;user=informix;password=informix";
try{

if ((ifxCon != null) && (!ifxCon.isClosed())){
System.out.println(" Reusing the existing Connection object from pool...");
return ifxCon;
}

System.out.println(" Creating a new Connection object from pool...");

//System.setProperty(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory");

System.setProperty(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.fscontext.RefFSContextFactory");

System.out.println("after setting initial context...");

System.setProperty(Context.PROVIDER_URL,dbURL);

ctx = new InitialContext();

System.out.println("after getting initial context...");

ds = (DataSource) ctx.lookup(dsName);

System.out.println("before ifxCon and assigning ds::::");

ifxCon = ds.getConnection(user,pwd);

ifxCon = (Connection) ds.getConnection();

System.out.println("After grtting ifxCon ");

}catch(Exception ifxe){
System.out.println("Exception while connecting toInformix <" + ifxe + ">");
}

return ifxCon;
}
}

   <<Less
About | Sitemap | Contact