Problem to generate Java package PL SQL in Jdeveloper

Hello

I have problem to create the java class package PL SQL in JDeveloper.

I use jdeveloper database navigator and right-click on a package and choose generate Java then in the Jpublisher window choose my controller view and accept other default values.

I call methods in the generated class in the Action of a button in my JSP page, but when I click the button it throws null pointer exception! I Fund one of the generated method return null and it lead to this exception.

protected DefaultContext __tx = null;

public DefaultContext getConnectionContext() throws SQLException {}

If (__tx == null) {}

__tx = (getConnection () == null)? DefaultContext.getDefaultContext (): new DefaultContext (getConnection ());

}

Return __tx;

};

public connection getConnection() throws SQLException

{

If (__onn! = null) return __onn;

ElseIf (__tx! = null) return __tx.getConnection ();

ElseIf (__dataSource! = null) __onn = __dataSource.getConnection ();

Return __onn;

}

I'm trying to generate the class in the model project and create DataControl to it and use the action method, but noting the change and I get null pointer again!

JDeveloper Versino = 11.1.1.7.0

I would like to ask you another question: why generate java packaging at all?

Where you want to call the package?

Back to your question: you should see the code as

Public Sub setDataSourceLocation (String dataSourceLocation) throws SQLException {}

javax.sql.DataSource dataSource;

try {}

Class cls = Class.forName ("javax.naming.InitialContext");

Object ctx = cls.newInstance ();

Meth java.lang.reflect.Method is CL. GetMethod ("search", new class [] {String.class});

dataSource = (javax.sql.DataSource) meth.invoke (ctx, new Object() {"java: comp/env /" + dataSourceLocation});

setDataSource (dataSource);

} catch (Exception e) {}

again throw java.sql.SQLException ("data source initialization error in" + dataSourceLocation + ":" + e.getMessage ());

}

}

in the generated code. This code search a data source (that you have defined for example on the Weblogic Server) by calling the method

setDataSourceLocaltion("jdbc/HRConnDS");

That look to the top of the n data source stores in the class variable.

Timo

Tags: Java

Similar Questions

Maybe you are looking for

  • Emoji application: Breton flag

    I see that almost all of the flags of the world are the emojis now, it is still not that Breton, Basque, or any of these countrys littles which must be recognized. I don't know how to apply, I say it here, sorry if it does not belong in this place.

  • Need to Diver WLAN for my C50-B14Z Satellite

    Hello I had a problem for the recovery of the software on my laptop satellite, so I download a Bing of 8.1 of Windows from the internet.But with the installation, there was no included wirelless driver. So I search the Internet on Satellite wireless

  • Pavilion g4-1065la. : FAILURE of a DISC ID HARD 1

    I just turned on my pc as usual and suddenly displays an error message indicating that I need to make a backup of my hard drive and perform a boot hard disk test.  I followed the steps and the hard drive test shows the following information: Test Dri

  • Disabled the SATA in the BIOS by mistake and will not be able to access the BIOS

    I disabled pata and sata by mistake in the bios on compaq windows vista desktop I can't go beyond screen compaq or access in the bios can someone help me with this please

  • With 0124 disk error disk failure...

    My Dell Latitude fell to the ground, and now it is not booting.  I run diagnostic and it can not find the hard drive.  I removed the hard drive twice and put it again.  And always get the same error. Please help... What do I do now...