From: | joao_vieira at siaconsultoria(dot)com(dot)br (Joao Vieira) |
---|---|
To: | |
Subject: | [Pljava-dev] ERROR: java.sql.SQLException: The url cannot benull |
Date: | 2006-02-28 11:21:50 |
Message-ID: | 000801c63c59$2d351fd0$3a0108c0@JOAOVIEIRA |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pljava-dev |
Hi Guy
The connection used is to the same database. We got some functions that use
the already existing jdbc connection (same used by the app). This same code
it's already working on oracle 10r2. The Compiere.getSQLValue function it's
working as well, inside the app.
Some code envolved:
public class Currency
{
public static BigDecimal base (BigDecimal p_Amount,
int p_C_CurrencyFrom_ID, Timestamp p_ConversionDate,
int p_AD_Client_ID, int p_AD_Org_ID)
throws SQLException
{
if (p_Amount == null || p_C_CurrencyFrom_ID == 0)
return null;
if (p_Amount.signum() == 0)
return p_Amount;
String sql = "SELECT ac.C_Currency_ID "
+ "FROM AD_ClientInfo ci"
+ " INNER JOIN C_AcctSchema ac ON
(ci.C_AcctSchema1_ID=ac.C_AcctSchema_ID) "
+ "WHERE ci.AD_Client_ID=?";
int C_CurrencyTo_ID = Compiere.getSQLValue(sql,
p_AD_Client_ID);
if (p_C_CurrencyFrom_ID == C_CurrencyTo_ID)
return p_Amount;
return convert(p_Amount, p_C_CurrencyFrom_ID,
C_CurrencyTo_ID,
p_ConversionDate, 0, p_AD_Client_ID, p_AD_Org_ID);
} // base
}
////////////////////////////////////////////////////////////////////////////
///////
Function declaration at postgreSQL:
CREATE OR REPLACE FUNCTION compiere.currencybase(amount "numeric",
c_currencyfrom_id int4, conversiondate timestamptz, ad_client_id int4,
ad_org_id int4)
RETURNS "numeric" AS
'org.compiere.sqlj.Currency.base(java.math.BigDecimal,int,java.sql.Timestamp
,int,int)'
LANGUAGE 'java' VOLATILE;
ALTER FUNCTION compiere.currencybase(amount "numeric", c_currencyfrom_id
int4, conversiondate timestamptz, ad_client_id int4, ad_org_id int4) OWNER
TO compiere;
GRANT EXECUTE ON FUNCTION compiere.currencybase(amount "numeric",
c_currencyfrom_id int4, conversiondate timestamptz, ad_client_id int4,
ad_org_id int4) TO compiere;
////////////////////////////////////////////////////////////////////////////
///////
SQL=SELECT COUNT(*) AS
Lines,c.ISO_Code,o.TotalLines,o.GrandTotal,currencyBase(o
.GrandTotal,o.C_Currency_ID,o.DateAcct, o.AD_Client_ID,o.AD_Org_ID) AS
ConvAmt F
ROM C_Order o INNER JOIN C_Currency c ON (o.C_Currency_ID=c.C_Currency_ID)
INNER
JOIN C_OrderLine l ON (o.C_Order_ID=l.C_Order_ID) WHERE o.C_Order_ID=?
GROUP BY
o.C_Currency_ID, c.ISO_Code, o.TotalLines, o.GrandTotal, o.DateAcct,
o.AD_Clien
t_ID, o.AD_Org_ID [12]
org.postgresql.util.PSQLException: ERROR: java.sql.SQLException: The url
cannot
be null; State=08001; ErrorCode=0
at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryEx
ecutorImpl.java:1512)
at
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutor
Impl.java:1297)
at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.ja
va:188)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Stat
ement.java:437)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(Abstract
Jdbc2Statement.java:353)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc
2Statement.java:257)
at sun.reflect.GeneratedMethodAccessor12.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.postgresql.ds.common.PooledConnectionImpl$StatementHandler.invoke
(PooledConnectionImpl.java:467)
at $Proxy1.executeQuery(Unknown Source)
at
org.compiere.util.CPreparedStatement.executeQuery(CPreparedStatement.
java:99)
at org.compiere.model.MTab.getTrxInfo(MTab.java:1422)
at org.compiere.apps.APanel.dataStatusChanged(APanel.java:823)
at org.compiere.model.MTab.fireDataStatusChanged(MTab.java:1790)
at org.compiere.model.MTab.setCurrentRow(MTab.java:1976)
at org.compiere.model.MTab.query(MTab.java:517)
at org.compiere.grid.GridController.query(GridController.java:534)
at org.compiere.apps.APanel.stateChanged(APanel.java:1004)
at javax.swing.JTabbedPane.fireStateChanged(JTabbedPane.java:290)
at
javax.swing.JTabbedPane$ModelListener.stateChanged(JTabbedPane.java:2
22)
There are anything you need to know?
Thanks in advance
Joao
-----Original Message-----
From: pljava-dev-bounces at gborg.postgresql.org
[mailto:pljava-dev-bounces at gborg.postgresql.org] On Behalf Of Guy Rouillier
Sent: ter?a-feira, 28 de fevereiro de 2006 02:51
To: pljava-dev at gborg.postgresql.org
Subject: Re: [Pljava-dev] ERROR: java.sql.SQLException: The url cannot
benull
Joao Vieira wrote:
> I've installed postgre 8.1 with pl/java (default installation), and
> when i try to execute some function that call the database again, i
> got the message above.
PL/Java is used to write procedural code within the database, i.e., stored
functions. JDBC is used by external applications to connect to the
database. One is independent of the other. Are you saying that from within
a Java stored function, you are trying to execute a JDBC connect to connect
to a different database? Show us the code you are using to connect, and
clarify where this code is running: in an external application or from
within a Java stored function.
--
Guy Rouillier
_______________________________________________
Pljava-dev mailing list
Pljava-dev at gborg.postgresql.org
http://gborg.postgresql.org/mailman/listinfo/pljava-dev
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas Hallgren | 2006-02-28 12:33:11 | [Pljava-dev] ERROR: java.sql.SQLException: The url cannot benull |
Previous Message | Guy Rouillier | 2006-02-28 05:50:40 | [Pljava-dev] ERROR: java.sql.SQLException: The url cannot be null |