Call Excel Macros function from Java
Hi All,
can u guide me How to call excel macros from java.
The thing is first I have to enable macros and then call the macors function.
Is this possible to call from Java. If yes guide me.
Thanks in Advance
Seems like something you'd have to do through COM.
http://sourceforge.net/projects/jacob-project/
HOW you do that is something you'll really have to figure out yourself, its not a Java question.
Similar Messages
-
Error PLS-00306 during calling PL/SQL function from Java
Hi all,
I am facing a problem during call of oracle PL/SQL function from java using CallableStatement.
I receive following error message.
java.sql.SQLException: ORA-06550: line 1, column 13:
PLS-00306: wrong number or types of arguments in call to 'EXPORT_HIST_ALARMS_FUNC'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
As per above error EXPORT_HIST_ALARMS_FUNC in oracle has this signature.
CREATE OR REPLACE FUNCTION EXPORT_HIST_ALARMS_FUNC(startDateTime VARCHAR2, endDateTime VARCHAR2, meType VARCHAR2) RETURN VARCHAR2 IS
END EXPORT_HIST_ALARMS_FUNC;
Above function I have called following way in java.
String sql = "begin ?:= EXPORT_HIST_ALARMS_FUNC(?, ?, ?); end;" ;
CallableStatement cStatement = null;
cStatement = connection.prepareCall(sql);
cStatement.registerOutParameter(1,Types.VARCHAR);
cStatement.setString(2,startDateTime);
cStatement.setString(3,endDateTime);
cStatement.setString(4,meType);
cStatement.execute();
msg = cStatement.getString(1);
Actually above function requires three input parameters and one return parameter.
During execution of above java code it throws SQLException and shows PLS-00306: wrong number or types of arguments in call to 'EXPORT_HIST_ALARMS_FUNC' error.
I have run this function directly from oracle with three parameters and run successfully and finally it returns string.
But I am unable to figure out why it doesn't run from above java code.
Please help regarding this.
Thanks.
Regards,
Shardul BankerTry this:
String sql = "begin ?:= EXPORT_HIST_ALARMS_FUNC(?, ?, ?); end;" ;
CallableStatement cStatement = null;
cStatement = connection.prepareCall(sql);
cStatement.registerOutParameter(1,Types.VARCHAR);
cStatement.setString(1,startDateTime);
cStatement.setString(2,endDateTime);
cStatement.setString(3,meType);
cStatement.execute();
msg = cStatement.getString(1);Regards,
Martijn Teigeler
Edited by: mTeigeler on Oct 13, 2007 10:22 AM -
Can I call a C function from Java (using JNI) ??
hello,
I need to call one C function from remote device and get its return value(o/p) (for my application it is device SSID ) and display in the client PC.
Is it possible in java without using SNMP connction?.
please give me idea about it.
I need this information as soon as possible.
Thank you.see JNI...
basically declare a native method in your java class, then run javah on the class thus generating a *.h file. Then implement the c/c++ function. Compile the c/c++ part as a shared library, and make sure its accessible from your LD_LIBRARY_PATH env variable.
Go through the steps in the JNI docs, and things shoulde be fine... hopefully ;) -
How to call a php function from java...
helllo fellow java developers!
Im trying to figure out how I can call a php function from my java code.
I know it sounds a bit unintiutive, seeing how java is a rich programming language, BUT java simply cannot do the task that the php script can do. It simply acts differently.
So I am trying to call a php function, that returns a string object, and capture that string object....
is this possible?
something like....
String strMyString = phpFunction( strVariable )
???????/ any ideaS?idea #1 - come up with a better plan that doesn't involve invoking php from java.
Give one example of something php can do that java can't.
idea #2 - forget java, and just write it in php.
Involving multiple frameworks/languages/runtime environments is a recipe for an overcomplicated solution that will be impossible to maintain.
I'd say keep it simple and stupid, and stick with one language.
If you're still hooked on the idea, maybe try [this link|http://www.infoq.com/news/2007/10/php-java-stack] -
Calling a javascript function from java code and getting tha value in Java
Hi,
I would like to call a Java script function confirmRemove() from Java code upon meeting a condition..
for example the code snippet is:
if(true){
// I want to call js confirmRemove() over here. And get the value of variable "answer" in this if block.
<html>
<head>
<script type="text/javascript">
function confirmRemove() {
var answer = confirm("Are you sure you want to Delete?")
</script>
</head>
<body>
<form>...Hi,
Back in 2003 I have used an Applet which contain java code and this java code was calling the java scripts ( different methods, DHTML etc..)
There was a component developed by NetScape called JSObject I am not sure it there is other third party component other then the JSObject
look at this article which shows how (based on JSObject)
[http://java.sun.com/products/plugin/1.3/docs/jsobject.html|http://java.sun.com/products/plugin/1.3/docs/jsobject.html]
Regards,
Alan Meio
London,UK -
Is it possible to call a C-function from Java?
Hey!
I have some extern variables written in C-language, can i get them into a java-file using java? How to do this otherwise?
Can i use Native interface java? Or is that only the opposite way?
Thanks
MikaelHey!
I have some extern variables written in C-language,
can i get them into a java-file using java? How to
do this otherwise?No.
>
Can i use Native interface java? Or is that only the
opposite way?If you wrap that C in C++ and compile it into a .dll or .so you can use JNI.
% -
ORA-00911: invalid character - Calling a function from Java..
Hi to all.. I have an issue when calling an oracle function from Java..
This is my Java code:
final StringBuffer strSql = new StringBuffer();
strSql.append("SELECT GET_TBL('II_2_1_6_5') AS TABLA FROM DUAL;");
st = conexion.createStatement();
rs = st.executeQuery(strSql.toString());
and in the executeQuery a SQLException is throwed:
java.sql.SQLException: ORA-00911: invalid character
I paste the query in TOAD and it works.. :S
anybody knows how can I solve this?Remove the Semicolon after Dual.
strSql.append("SELECT GET_TBL('II_2_1_6_5') AS TABLA FROM DUAL");
Sushant -
On making call to Oracle procedures from Java, Value becomes null on oracle
We are using some user defined Oracle data types in my Java/J2EE application
and some of them are Oracle collections(ex. VARRAY).
We are making a call to Procedures/Functions from Java, there are some
parameters of user defined data types declared in the
procedures/functions, from java the values are properly setting to these
user defined data type parameters and sending to Procedures.
We are not getting any exception at Java side and Oracle side and values
are becoming blank/null at oracle procedure side for the parameters of
user defined data types.
But when do the count of collection of user defined data type then it is
properly giving the size of collection(VARRAY).
When we are trying to read the values from the collection(VARRAY) it is
giving blank/null value and there is no exception.
Please let me know if you have any suggestion on this?user7671994 wrote:
When we are trying to read the values from the collection(VARRAY) it is
giving blank/null value and there is no exception.If you are talking about VARCHAR2 parameters of the objects - then you should add orai18n.jar to classpath. -
Calling a SP or Function from Java receiving a geometry(MDSYS.SDO_GEOMETRY)
Hi there,
What I want to do is: calling a stored procedure OR function from Java with a String-variable as input and receiving a geometry (SDO_GEOMETRY).
I’m facing currently the problem of calling a stored function on oracle 11g from Java using JPA (EclipseLink), Spring 2.5.6 returning an MDSYS.SDO_GEOMETRY object.
I’ve tried to call a stored procedure with MDSYS.SDO_GEOMETRY as an output parameter instead, but with no success.
The function’s signature looks like this:
CREATE or REPLACE
FUNCTION GET_GEO_BRD_FUNCTION(p_geo_brd_id IN VARCHAR2) RETURN MDSYS.SDO_GEOMETRY AS
sdo_geom MDSYS.SDO_GEOMETRY := null;
BEGIN
/* do some fancy stuff on the database side */
SELECT sp_geom
INTO sdo_geom
FROM geo_brd WHERE id = p_geo_brd_id;
RETURN sdo_geom;
END;
The calling code looks like this:
MyClass extends JpaDaoSupport{
/** logger */
protected static final ILogger LOG = LogFactory.getLogger(MyClass.class);
* {@inheritDoc}
* @see com.example.MyClass#calculateGeometry(java.lang.String)
@Override
public JGeometry calculateGeometry(final String id) {
JGeometry geometry = null;
final JpaCallback action = new JpaCallback() {
@Override
public Object doInJpa(final EntityManager em) throws PersistenceException {
final Session session = JpaHelper.getEntityManager(em).getActiveSession();
final StoredFunctionCall functionCall = new StoredFunctionCall();
functionCall.setProcedureName("GET_GEO_BRD_FUNCTION");
functionCall.addNamedArgument("p_geo_brd_id");
functionCall.setResult("sdo_geom", Oracle.sql.STRUCT.class);
final ValueReadQuery query = new ValueReadQuery();
query.setCall(functionCall);
query.addArgument("p_geo_brd_id");
final ArrayList args = new ArrayList();
args.add("2e531e62-2105-4522-978a-ab8baf19e273");// hardcoded for test
final Object result = session.executeQuery(query, args);
return result;
final STRUCT result = (STRUCT) this.getJpaTemplate().execute(action);
try {
geometry = JGeometry.load(result);
} catch (final SQLException e) {
MyClass.LOG.error("Error loading JGeometry from STRUCT.", e);
return null;
return geometry;
And when I execute the query I get the following error:
Internal Exception: java.sql.SQLException: ORA-06550: Row 1, Column 13:
PLS-00382: expression is of wrong type
ORA-06550: Row 1, Column 7:
PL/SQL: Statement ignored
Error Code: 6550
Call: BEGIN ? := GET_GEO_BRD_FUNCTION(p_geo_brd_id=>?); END;
bind => [=> sdo_geom, 2e531e62-2105-4522-978a-ab8baf19e273]
Query: ValueReadQuery()
So I thought may be let's try it with a stored procedure instead...
The procedure looks like this:
CREATE or REPLACE
PROCEDURE GET_GEO_BRD_PROCEDURE(p_geo_brd_id IN VARCHAR2, sdo_geom OUT MDSYS.SDO_GEOMETRY) AS
BEGIN
/* do some fancy stuff on the database side */
SELECT sp_geom
INTO sdo_geom
from geo_brd where id = p_geo_brd_id;
END;
The calling Java code in case of the stored procedure looks like this (only the content of the JPACallback has changed):
@Override
public Object doInJpa(final EntityManager em) throws PersistenceException {
final Session session = JpaHelper.getEntityManager(em).getActiveSession();
final StoredProcedureCall spCall = new StoredProcedureCall();
spCall.setProcedureName("GET_GEO_BRD_PROCEDURE");
spCall.addNamedArgument("p_geo_brd_id", "p_geo_brd_id", String.class);
spCall.addNamedOutputArgument("sdo_geom", "sdo_geom", OracleTypes.STRUCT);
final ValueReadQuery query = new ValueReadQuery();
query.setCall(spCall);
query.addArgument("p_geo_brd_id"); // input
final List args = new ArrayList();
args.add("2e531e62-2105-4522-978a-ab8baf19e273");// hardcoded for test
final Object result = session.executeQuery(query, args);
return result;
And when I execute the query I get the following error:
java.sql.SQLException: ORA-06550: Row 1, Column 13:
PLS-00306: wrong number or types of arguments in call to 'GET_GEO_BRD_PROCEDURE'
ORA-06550: Row 1, Column 7:
PL/SQL: Statement ignored
So both exceptions look quite similar.
I guess in both cases the exception description leads to the assumption, that the wrong type for the return value / output parameter is used…
So - how can a receive a MDSYS_SDO_GEOMETRY object from a stored procedure or stored function in Java ?
What is wrong in the Java code?
Thank you in advance for any suggestions!
Yours,
Chris
Edited by: user3938161 on 20.12.2011 07:46
Edited by: user3938161 on Dec 20, 2011 8:06 AM: added variable declaration of JGeometry geometry in source codeThanks, that did the trick! ;-)
Here is now the code for stored procedure and function for anybody else encountering the same troubles... (be aware of the parameter order and/or naming!)
Code for stored functions:
final JpaCallback action = new JpaCallback() {
@Override
public Object doInJpa(final EntityManager em) throws PersistenceException {
final Session session = JpaHelper.getEntityManager(em).getActiveSession();
* Using CallableStatement for stored functions
STRUCT st = null;
CallableStatement cs = null;
final DatabaseLogin login = session.getLogin();
final Connection _conn = (Connection) login.connectToDatasource(session.getDatasourceLogin().buildAccessor(), session);
try {
try {
cs = _conn.prepareCall("{? = call GET_GEO_BRD_FUNCTION(?)}");
cs.registerOutParameter(1, OracleTypes.STRUCT, "MDSYS.SDO_GEOMETRY");
cs.setString(2, "2e531e62-2105-4522-978a-ab8baf19e273");//TODO: hardcoded for test
cs.execute();
} catch (final SQLException e) {
MyClass.LOG.error("An exception occured calling the stored procedure", e);
if (cs != null) {
//reading geometry from the database
try {
st = (STRUCT) cs.getObject(1);
} catch (final SQLException e) {
MyClass.LOG.error("An exception occured converting the query result to oracle.sql.STRUCT", e);
} finally {
try {
if (_conn != null && !_conn.isClosed()) {
_conn.close();
} catch (final SQLException e) {
MyClass.LOG.error("An exception occured on closing the database connection.", e);
return st;
final STRUCT result = (STRUCT) this.getJpaTemplate().execute(action);
The code for stored procedure solution:
final JpaCallback action = new JpaCallback() {
@Override
public Object doInJpa(final EntityManager em) throws PersistenceException {
final Session session = JpaHelper.getEntityManager(em).getActiveSession();
* Using CallableStatement for stored procedure
STRUCT st = null;
CallableStatement cs = null;
final DatabaseLogin login = session.getLogin();
final Connection _conn = (Connection) login.connectToDatasource(session.getDatasourceLogin().buildAccessor(), session);
try {
try {
cs = _conn.prepareCall("{call GET_GEO_BRD_PROCEDURE(?,?)}");
cs.setString("p_geo_brd_id", "2e531e62-2105-4522-978a-ab8baf19e273");
cs.registerOutParameter("sdo_geom", OracleTypes.STRUCT, "MDSYS.SDO_GEOMETRY");
cs.execute();
} catch (final SQLException e) {
MyClass.LOG.error("An exception occured calling the stored procedure", e);
if (cs != null) {
//reading geometry from the database
try {
st = (STRUCT) cs.getObject("sdo_geom");
} catch (final SQLException e) {
MyClass.LOG.error("An exception occured converting the query result to oracle.sql.STRUCT", e);
} finally {
try {
if (_conn != null && !_conn.isClosed()) {
_conn.close();
} catch (final SQLException e) {
MyClass.LOG.error("An exception occured on closing the database connection.", e);
return st;
final STRUCT result = (STRUCT) this.getJpaTemplate().execute(action); -
Calling a PL/SQL function from java
I would like to call a pl/sql function from java. My pl/sql function is taking arrays of records as parameters. How do i proceed? Which specific oracle packages do I have to import?
Please send an example.
TIA,
Darko GuberinaDocumentation here: http://download-uk.oracle.com/docs/cd/B14117_01/java.101/b10983/datamap.htm#sthref185
says JPublisher can publish records too.
But when I change the example given at http://download-uk.oracle.com/docs/cd/B14117_01/java.101/b10983/datamap.htm#sthref190 as following:
PACKAGE "COMPANY" AS
type emp_rec is record (empno number, ename varchar2(10));
type emp_list is varray(5) of emp_rec;
type factory is record (
name varchar(10),
emps emp_list
function get_factory(p_name varchar) return factory;
END;
then I see <unknown type or type not found> at sql or java files generated. Any ideas? -
Hi
How do I call a C function from a java applet. Any ideas.
Thanks
JayHow do I call a C function from a java applet.
You're going to run into problems here even after you figure out all the JNI details. Loading a shared object from an applet violates the security model - you will have to sign the applet. In addition, to be cross-platform (I'm using linux now), you will have to provide multiple dll/so - one for each architecture... -
Calling OCI functions from Java
Is it possible to call OCI's API functions from Java and create a Lightweight Session ?
Please help me out.I too would like to know how this can be accomplished. I have
seen several posts that claim it is possible with Oracle91. -
HI!
What's the best way (and simple) to call DLL function from JAVA.
DLL function (developed in C) has two input parameters (string) and return an integer.
Could you help with an example?
Thanks a lot.Do a google search for 'JNI tutorial' and it will turn up hundreds of examples.
-
Calling c function from java!!
hi all,
I want to call c function from java . I have gone through the link http://java.sun.com/docs/books/tutorial/native1.1/stepbystep/index.html for JNI.
According to this link we need to write the native method implementation in such a way that the method signature should exactly match the method signature created in the header file.
My problem is that i have a c application which i cannot modify in any ways i.e., i cannot change its code. But i want to call its function from my java code.
Please suggest me appropriate solution for this. Please let me know whether it can be done using JNI or is there any other method for this.
thanksThis link is amazing since those sources were wrote in 1998 and I started to develop JNative in 2004. I did not found them when I started.
Since JNative can deal with callbacks and probably COM in a near future, I expect to see it living to Dolphin at least.
--Marc (http://jnative.sf.net) -
Calling Window's Dll Functions from Java
Hello Audience,
Is there a way to call Win32/64 based Dynamic-Link-Library functions from Java?
Thanks,
GenKabukiYes.
In general, if you are trying to call functions in an existing dll, you will have to write a "wrapper" dll that meets the java jni interface requires. There are tools around wich purport to generate these for you. Do a google serach; among other tools, you should turn up JACE.
Maybe you are looking for
-
Setup Windows XP SP3 + Office 2007 Pro Also, tested on Windows 7 64x + Office 2007 Pro Same Issues. The steps used are: 1) Open Adobe Acrobat 9.0 2) Click File 3) Combine 4) Merge Files into a single PDF 5) Add Files (select the required files) 6) C
-
Hi I am running mac os x 10.7.5.I have installed jre7u_17 in my mac.But uninstalled it by removing javaAppletPlugin.plugin and when i am trying to install jre7u5 it prompting me that "Higher Version of java already installed.But in terminal if i ru
-
Hi All, Is there is any BAPI for the T-Code MB31? Regards, Raghu
-
Best HD Upgrade Strategy?
I have a MacPro ("Early 2008") 2.8 GHz Quad Core 45-nm Intel Xeon E5462 2008 with 8GB RAM. I am running it as an office server with Mountain Lion Server. Two years ago I upgraded the two harddrives to 3TB each ... but at the time, did not install the
-
Hi all: I´m trying to connect to MS SQL Server DB, trought DBCO transaction, filling data such a: DB Connection: MY_CONNECT DBMS: MSS (SQL server) USER: my_user PASS: my_password CONN. INFO: ("MSSQL_SERVER=xxx.xxx.xxx.xxx MSSQL_DBNA