Wednesday, December 13, 2006

making direct db conn

it didnt get published for some reason hopefully it will now.
import="java.sql.PreparedStatement
import="java.sql.Statement

import="java.util.Hashtable

import="javax.naming.InitialContext"


import="java.text.DecimalFormat"


import="javax.naming.Context"

import="com.jpmchase.srgt.util.SrgtProperties"

Connection conn = null;Statement s = null;
ResultSet rs = null;
PreparedStatement ps = null;
List result = null;
String prividerURL=null;
//Getting the url and datasource from srgtProperties file
String providerURL=SrgtProperties.getProperty("perf_url");
String jndiDS=SrgtProperties.getProperty("perf_srgt_ds");
System.out.println("Provider URL is :"+providerURL);
Hashtable ht = new Hashtable();
ht.put(Context.PROVIDER_URL,providerURL);
ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
InitialContext ctx = new InitialContext(ht);
javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup(jndiDS);
conn=ds.getConnection();
ps = conn.prepareStatement(sqlBuff.toString());

No comments: