Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

setting DataSource in J2ee  RSS feed

 
Aamer jawwad
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I am using oracle 8i and J2EE server from sun.
How can i set up the DataSource
try{
InitialContext ic = new InitialContext();
DataSource ds = (DataSource)ic.lookup ("jdbc/oracleDS");
Connection conn = ds.getConnection();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("Select * from movies where year = " + 2000);

conn.close();
}catch(Exception ex){
System.out.println(ex);
}
I am getting exception. If possible someone can tell me what files i.e xml or any other property files I have to change to set the server so it can use the datasource.
thanks
 
Maximilian Trenks
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
post the exception, so we can help ya.
 
Aamer jawwad
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try{
Context ic = new InitialContext();

DataSource ds = (DataSource).lookup "jdbc/Oracle");

System.out.println(ds.toString());
//Here it prints out
//com.sun.enterprise.resource.JdbcDataSource@6bba64

Connection conn = ds.getConnection("movies","movies");
// On Conn, I am getting an exception
conn.close();
}catch(Exception ex){
System.out.println(ex);
}
Exception I am getting is
com.sun.enterprise.InvocationException
My userCongig.bat file has
set J2EE_CLASSPATH=C:\drivers\classes12.zip;
My resource.properties file has
jdbcDataSource.5.name=jdbc/Oracle
jdbcDataSource.5.url=jdbc\ racle\:thin\:@localhost\:1526\ B816
jdbcDriver.2.name=oracle.jdbc.driver.OracleDriver
I will highly apprreciate any help
thanks
 
Al Newman
Ranch Hand
Posts: 716
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post the stacktrace thrown by the exceptions, dude!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!