Interacting with database from web
Here's the situation. I have some dumb terminal (client) that interacts with a server, which holds a database. I want users to be able to query that database from the web and have it create a page with the results.
Since I did not know cgi, or servlets, etc., I devised a primitive method. I was planning on having the database create html files and send it to the webserver so the users can interact with the premade html files. This is not a good idea :) since there would be thousands of files made.
What is the best way to interact with the database? Servlets? Can you use servlets freely or do you need a commercial license? Please exuse my newbiness :)
You don't need any commercial software to use Servlets and JSPs.
Have a look at the Tomcat servlet engine from Jakarta:
http://jakarta.apache.org
I expect that if you search these forums (particularly the JDBC and JavaServer Pages forums) you'll find various examples of JSPs and Servlets that connect to a database to allow primitive querying capabilities.
Hope this helps.
Similar Messages
-
Interacting with adapters from Spring Component, especially db adapter
hello everybody,
I try to interact with adapters from my Spring component. I actually try to start my query and to receive the result in my Spring Component.
I've already search for documentation about api to communicate with it or documentation about the classes created during the db adapter creation... But .. no result..
So I'm trying to do it my self but I encounter some problems when I'm trying to call the query on the dbAdapter and trying to "play" with the classes created by the db adapter.
Could anyone say me HOW we can interact with adapters from Spring component (in the class bean)?
Also, how can I access to the variables? Is there an equivalent of "getVariableData" and "setVariableData" that I can use in the Spring Component? with which jar and/or import?
I copy/paste what I've already done.
So My Composite contains a Web Service "getStatusByCC" which is linked to a Mediator. The Mediator calls the Spring Component "SprinCallDB" and the Spring Component is linked to a database adapter called "getCreditValidation". The transformation in the mediator component is correct (I test it without the call to the db and it works fine)
First, there is the classes created and added to my project by the db adapter :
Creditcardinfo.java
package com.oracle.xmlns.pcbpel.adapter.db.top.getcreditvalidation;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
* <p>Java class for Creditcardinfo complex type.
* <p>The following schema fragment specifies the expected content contained within this class.
* <pre>
* <complexType name="Creditcardinfo">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="ccnumber">
* <simpleType>
* <restriction base="{http://www.w3.org/2001/XMLSchema}string">
* <maxLength value="20"/>
* </restriction>
* </simpleType>
* </element>
* <element name="status" minOccurs="0">
* <simpleType>
* <restriction base="{http://www.w3.org/2001/XMLSchema}string">
* <maxLength value="20"/>
* </restriction>
* </simpleType>
* </element>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Creditcardinfo", propOrder = {
"ccnumber",
"status"
public class Creditcardinfo {
@XmlElement(required = true)
protected String ccnumber;
protected String status;
* Gets the value of the ccnumber property.
* @return
* possible object is
* {@link String }
public String getCcnumber() {
return ccnumber;
* Sets the value of the ccnumber property.
* @param value
* allowed object is
* {@link String }
public void setCcnumber(String value) {
this.ccnumber = value;
* Gets the value of the status property.
* @return
* possible object is
* {@link String }
public String getStatus() {
return status;
* Sets the value of the status property.
* @param value
* allowed object is
* {@link String }
public void setStatus(String value) {
this.status = value;
CreditcardinfoCollection.java
package com.oracle.xmlns.pcbpel.adapter.db.top.getcreditvalidation;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
* <p>Java class for CreditcardinfoCollection complex type.
* <p>The following schema fragment specifies the expected content contained within this class.
* <pre>
* <complexType name="CreditcardinfoCollection">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="Creditcardinfo"
* type="{http://xmlns.oracle.com/pcbpel/adapter/db/top/getCreditValidation}Creditcardinfo" maxOccurs="unbounded" minOccurs="0"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "CreditcardinfoCollection", propOrder = {
"creditcardinfo"
public class CreditcardinfoCollection {
@XmlElement(name = "Creditcardinfo")
protected List<Creditcardinfo> creditcardinfo;
* Gets the value of the creditcardinfo property.
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the creditcardinfo property.
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getCreditcardinfo().add(newItem);
* </pre>
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Creditcardinfo }
public List<Creditcardinfo> getCreditcardinfo() {
if (creditcardinfo == null) {
creditcardinfo = new ArrayList<Creditcardinfo>();
return this.creditcardinfo;
GetCreditValidationSelectCcnb.java
package com.oracle.xmlns.pcbpel.adapter.db.top.getcreditvalidation;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
* <p>Java class for getCreditValidationSelect_ccnb complex type.
* <p>The following schema fragment specifies the expected content contained within this class.
* <pre>
* <complexType name="getCreditValidationSelect_ccnb">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="ccnb" type="{http://www.w3.org/2001/XMLSchema}string"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "getCreditValidationSelect_ccnb", propOrder = {
"ccnb"
public class GetCreditValidationSelectCcnb {
@XmlElement(required = true)
protected String ccnb;
* Gets the value of the ccnb property.
* @return
* possible object is
* {@link String }
public String getCcnb() {
return ccnb;
* Sets the value of the ccnb property.
* @param value
* allowed object is
* {@link String }
public void setCcnb(String value) {
this.ccnb = value;
ObjectFactory.java
package com.oracle.xmlns.pcbpel.adapter.db.top.getcreditvalidation;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.bind.annotation.XmlRegistry;
import javax.xml.namespace.QName;
* This object contains factory methods for each
* Java content interface and Java element interface
* generated in the com.oracle.xmlns.pcbpel.adapter.db.top.getcreditvalidation package.
* <p>An ObjectFactory allows you to programatically
* construct new instances of the Java representation
* for XML content. The Java representation of XML
* content can consist of schema derived interfaces
* and classes representing the binding of schema
* type definitions, element declarations and model
* groups. Factory methods for each of these are
* provided in this class.
@XmlRegistry
public class ObjectFactory {
private final static QName CreditcardinfoCollectionQNAME = new QName("http://xmlns.oracle.com/pcbpel/adapter/db/top/getCreditValidation", "CreditcardinfoCollection");
private final static QName GetCreditValidationSelectCcnbInputParametersQNAME = new QName("http://xmlns.oracle.com/pcbpel/adapter/db/top/getCreditValidation", "getCreditValidationSelect_ccnbInputParameters");
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.oracle.xmlns.pcbpel.adapter.db.top.getcreditvalidation
public ObjectFactory() {
* Create an instance of {@link CreditcardinfoCollection }
public CreditcardinfoCollection createCreditcardinfoCollection() {
return new CreditcardinfoCollection();
* Create an instance of {@link GetCreditValidationSelectCcnb }
public GetCreditValidationSelectCcnb createGetCreditValidationSelectCcnb() {
return new GetCreditValidationSelectCcnb();
* Create an instance of {@link Creditcardinfo }
public Creditcardinfo createCreditcardinfo() {
return new Creditcardinfo();
* Create an instance of {@link JAXBElement }{@code <}{@link CreditcardinfoCollection }{@code >}}
@XmlElementDecl(namespace = "http://xmlns.oracle.com/pcbpel/adapter/db/top/getCreditValidation", name = "CreditcardinfoCollection")
public JAXBElement<CreditcardinfoCollection> createCreditcardinfoCollection(CreditcardinfoCollection value) {
return new JAXBElement<CreditcardinfoCollection>(_CreditcardinfoCollection_QNAME, CreditcardinfoCollection.class, null, value);
* Create an instance of {@link JAXBElement }{@code <}{@link GetCreditValidationSelectCcnb }{@code >}}
@XmlElementDecl(namespace = "http://xmlns.oracle.com/pcbpel/adapter/db/top/getCreditValidation", name = "getCreditValidationSelect_ccnbInputParameters")
public JAXBElement<GetCreditValidationSelectCcnb> createGetCreditValidationSelectCcnbInputParameters(GetCreditValidationSelectCcnb value) {
return new JAXBElement<GetCreditValidationSelectCcnb>(_GetCreditValidationSelectCcnbInputParameters_QNAME, GetCreditValidationSelectCcnb.class, null, value);
package-info.java
@javax.xml.bind.annotation.XmlSchema(namespace = "http://xmlns.oracle.com/pcbpel/adapter/db/top/getCreditValidation", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package com.oracle.xmlns.pcbpel.adapter.db.top.getcreditvalidation;
GetCreditValidation_ptt.java
package getcreditvalidation.validationforccwithspring.creditcardvalidation.db.adapter.pcbpel.com.oracle.xmlns;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.ParameterStyle;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.ws.Action;
// !DO NOT EDIT THIS FILE!
// This source file is generated by Oracle tools
// Contents may be subject to change
// For reporting problems, use the following
// Version = Oracle WebServices (11.1.1.0.0, build 111209.0821.28162)
@WebService(targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/db/CreditCardValidation/validationForCCWithSpring/getCreditValidation",
name="getCreditValidation_ptt")
@XmlSeeAlso(
{ com.oracle.xmlns.pcbpel.adapter.db.top.getcreditvalidation.ObjectFactory.class })
public interface GetCreditValidation_ptt
@WebMethod
@SOAPBinding(parameterStyle=ParameterStyle.BARE)
@Action(input="http://xmlns.oracle.com/pcbpel/adapter/db/CreditCardValidation/validationForCCWithSpring/getCreditValidation/getCreditValidation_ptt/getCreditValidationSelectRequest",
output="http://xmlns.oracle.com/pcbpel/adapter/db/CreditCardValidation/validationForCCWithSpring/getCreditValidation/getCreditValidation_ptt/getCreditValidationSelectResponse")
@WebResult(targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/db/top/getCreditValidation",
partName="CreditcardinfoCollection", name="CreditcardinfoCollection")
public com.oracle.xmlns.pcbpel.adapter.db.top.getcreditvalidation.CreditcardinfoCollection getCreditValidationSelect(@WebParam(targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/db/top/getCreditValidation",
partName="getCreditValidationSelect_inputParameters", name="getCreditValidationSelect_ccnbInputParameters")
com.oracle.xmlns.pcbpel.adapter.db.top.getcreditvalidation.GetCreditValidationSelectCcnb getCreditValidationSelect_inputParameters);
Here there is the classes linked to the Spring Component and the configuration file :
SpringCallDB
<?xml version="1.0" encoding="windows-1252" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:sca="http://xmlns.oracle.com/weblogic/weblogic-sca"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/tool http://www.springframework.org/schema/tool/spring-tool-2.5.xsd http://xmlns.oracle.com/weblogic/weblogic-sca META-INF/weblogic-sca.xsd">
<!--Spring Bean definitions go here-->
<sca:service name="CCSpringService" target="CCSpringImpl"
type="validationForCC.spring.service.api.ISpringCCService"/>
<bean id="CCSpringImpl" class="validationForCC.spring.service.impl.SpringCCServiceImpl">
<property name="dbRequest" ref="getCreditValidation"/>
</bean>
<sca:reference type="getcreditvalidation.validationforccwithspring.creditcardvalidation.db.adapter.pcbpel.com.oracle.xmlns.GetCreditValidation_ptt"
name="getCreditValidation"/>
</beans>
CreditCardNumber.java
package validationForCC.spring.model;
public class CreditCardNumber {
private String ccNumber;
public CreditCardNumber() {
super();
public void setCcNumber(String nb){
this.ccNumber = nb;
public String getCcNumber(){
return ccNumber;
Response.java
package validationForCC.spring.model;
public class Response {
String reply;
public Response() {
super();
public void setReply(String rep){
this.reply = rep;
public String getReply(){
return reply;
ISpringCCService.java
package validationForCC.spring.service.api;
import validationForCC.spring.model.CreditCardNumber;
import validationForCC.spring.model.Response;
public interface ISpringCCService {
* @param ccn
* @return
public Response getCCStatus(CreditCardNumber ccn);
SpringCCServiceImpl.java
package validationForCC.spring.service.impl;
import com.oracle.xmlns.pcbpel.adapter.db.top.getcreditvalidation.*;
import java.util.List;
import javax.jws.WebParam;
import validationForCC.spring.model.CreditCardNumber;
import validationForCC.spring.model.Response;
public class SpringCCServiceImpl {
public SpringCCServiceImpl() {
super();
private getcreditvalidation.validationforccwithspring.creditcardvalidation.db.adapter.pcbpel.com.oracle.xmlns.GetCreditValidation_ptt dbRequest;
public Response getCCStatus(CreditCardNumber ccn){
Response resp = new Response();
CreditcardinfoCollection resultSet;
GetCreditValidationSelectCcnb selectCCNb = new GetCreditValidationSelectCcnb();
selectCCNb.setCcnb(ccn.getCcNumber());
resultSet = dbRequest.getCreditValidationSelect(selectCCNb);
resp.setReply((resultSet.getCreditcardinfo().get(0).getStatus()));
return resp;
public getcreditvalidation.validationforccwithspring.creditcardvalidation.db.adapter.pcbpel.com.oracle.xmlns.GetCreditValidation_ptt getDbRequest(){
return dbRequest;
public void setDbRequest(getcreditvalidation.validationforccwithspring.creditcardvalidation.db.adapter.pcbpel.com.oracle.xmlns.GetCreditValidation_ptt dbReq){
this.dbRequest = dbReq;
So, the line which is the cause of the error is the following :
resultSet = dbRequest.getCreditValidationSelect(selectCCNb);
in the SpringCCServiceImpl.java class
And there is the error I obtain :
+weblogic.sca.api.ScaException: java.lang.RuntimeException: BINDING.JCA-12563 Exception occured when binding was invoked. Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'getCreditValidationSelect' failed due to: DBReadInteractionSpec Execute Failed Exception. Query name: [getCreditValidationSelect], Descriptor name: [getCreditValidation.Creditcardinfo]. Caused by Exception [EclipseLink-6003] (Eclipse Persistence Services - 2.3.1.v20111018-r10243): org.eclipse.persistence.exceptions.QueryException Exception Description: The number of arguments provided to the query for execution does not match the number of arguments in the query definition. Query: ReadAllQuery(name="getCreditValidationSelect" referenceClass=Creditcardinfo ). See root exception for the specific exception. This exception is considered not retriable, likely due to a modelling mistake. ". The invoked JCA adapter raised a resource exception. Please examine the above error message carefully to determine a resolution.
Exception occured when binding was invoked. Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'getCreditValidationSelect' failed due to: DBReadInteractionSpec Execute Failed Exception. Query name: [getCreditValidationSelect], Descriptor name: [getCreditValidation.Creditcardinfo]. Caused by Exception [EclipseLink-6003] (Eclipse Persistence Services - 2.3.1.v20111018-r10243): org.eclipse.persistence.exceptions.QueryException Exception Description: The number of arguments provided to the query for execution does not match the number of arguments in the query definition. Query: ReadAllQuery(name="getCreditValidationSelect" referenceClass=Creditcardinfo ). See root exception for the specific exception. This exception is considered not retriable, likely due to a modelling mistake. ". The invoked JCA adapter raised a resource exception. Please examine the above error message carefully to determine a resolution.
java.lang.RuntimeException: BINDING.JCA-12563 Exception occured when binding was invoked. Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'getCreditValidationSelect' failed due to: DBReadInteractionSpec Execute Failed Exception. Query name: [getCreditValidationSelect], Descriptor name: [getCreditValidation.Creditcardinfo]. Caused by Exception [EclipseLink-6003] (Eclipse Persistence Services - 2.3.1.v20111018-r10243): org.eclipse.persistence.exceptions.QueryException Exception Description: The number of arguments provided to the query for execution does not match the number of arguments in the query definition. Query: ReadAllQuery(name="getCreditValidationSelect" referenceClass=Creditcardinfo ). See root exception for the specific exception. This exception is considered not retriable, likely due to a modelling mistake. ". The invoked JCA adapter raised a resource exception. Please examine the above error message ca
Exception occured when binding was invoked. Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'getCreditValidationSelect' failed due to: DBReadInteractionSpec Execute Failed Exception. Query name: [getCreditValidationSelect], Descriptor name: [getCreditValidation.Creditcardinfo]. Caused by Exception [EclipseLink-6003] (Eclipse Persistence Services - 2.3.1.v20111018-r10243): org.eclipse.persistence.exceptions.QueryException Exception Description: The number of arguments provided to the query for execution does not match the number of arguments in the query definition. Query: ReadAllQuery(name="getCreditValidationSelect" referenceClass=Creditcardinfo ). See root exception for the specific exception. This exception is considered not retriable, likely due to a modelling mistake. ". The invoked JCA adapter raised a resource exception. Please examine the above error message carefully to determine a resolution. +
Any idea is welcome! :)
If you have great urls to communicate with adapters and variables from spring component, don't hesitate to post it!
Thanks in advance,
Sophie
Edited by: 953383 on Sep 18, 2012 6:41 AM
Edited by: 953383 on Sep 18, 2012 6:43 AM
Edited by: 953383 on Sep 18, 2012 6:46 AMHello,
Finally, I can interact with my db adapter.
But, I ask you the following question : is there any documentation on the manner to interact with adapters and other component of the suite and on all classes generated?
Thanks in advance,
Sophie -
How IVR interact with database. Any idea?
I mean to say mechanism it follows to populate data using IVR system for inbound and outbound calls.AnkitAshokAggarwal wrote:
How IVR interact with database. Any idea?
I mean to say mechanism it follows to populate data using IVR system for inbound and outbound calls.
SQL is the only mechanism to populate data using IVR system for inbound and outbound calls. -
Using cfform to interact with databases
hi there, I am just trying to get ito using the cfform tag,
and I thought it would be as easy to do insert into table ect using
server behaviours, but clearly not! could somebody point me the
right direction of some good tutorials please, to show me how to do
all the wonderful interaction with Databases that I have been able
to do with normal dreamweaver html forms...
Many thanksI have found that <cfform> is a bit of a pain. I prefer
using the standard <form>
and writing the SQL myself. Much cleaner!
<cfquery ...
INSERT INTO t_someTable
(column1, column2)
VALUES
'#trim(form.field1)#',
'#trim(form.field2)#',
</cfquery> -
Help!! Error Generating demo paper report with barcode from web
Now I am using Oracle 9i AS Release 2 + Report 9i and I try to run the demo paper report "ShippingManifest.rdf" which includes Bar Code inside. But I cannot launch the report successfully. The problem seems the report service cannot call build in package ORA_JAVA. Btw, with the same report, I can run this report on the report bulider without any problem on the same machine.
Actaully, can I launch this demo report from web? If so, how can I includes classpath for the bulid in package?
or I must use JSP report instead?
Thanks & Regards
Louis LeiHi Philipp,
My environment is Windows 2000. After I added by classPath in rwEng, my report can launch on web now. Thanks you for your help.
But, another question is: I can display chinese character on both HTML and PDF if I run the report on report bulider. But if I run the report on the web, the Chinese charecter can not be displayed on boht HTML and PDF. I tried to modify the NLS_LANG in registry and environment variable, but also failed.
On the other hand, I use http://www.abc.com:7778/reports/rwservlet/showenv?server=rep_winrms to display the environment. It always return TRADITIONAL CHINESE_TAIWAN.UTF8 for environment variable NLS_LANG. Do you want know how to modify this value?
Thanks & Regards,
Louis Lei -
How to interact with database?
Hi,
I am exploring sampleportal application in Weblogic Portal8.1 SP4. There in login portlet they are using login.jsp file which uses examples.login.DirectorBacking class for login form authentication. DirectorBacking class uses default com.bea.p13n.security.Authentication class’s authenticate method for authentication. I could not understand the basic functionality of Authentication class as how it interacts with the database.
Can we use simple JDBC for the login authentication in login.jsp ?U can define several authentication realms - which could be RDBMS, LDAP etc.
Does that answer your question? -
Query regarding XI interaction with database
Hi all,
I have got the Oracle database and SAP R/3 system
Is it possible that through JDBC adapter ,
a) Direct fetching of data from database
b) Data should come in XI and after mapping should be
posted in SAP R/3 .i.e complete automated process
c) Is it possible to put direct query statement in XI
while connection with database through JDBC adapter
E.g For fetching the vendor data from database
Select * from ....
Thanks in advance
Shikha JainShikha,
<i>a) Direct fetching of data from database</i>
In the JDBC Sender adapter you have to mention the SQL Query.
<i>b) Data should come in XI and after mapping should be
posted in SAP R/3 .i.e complete automated process</i>
This is what XI does. There is no manual intervention needed.
<i>c) Is it possible to put direct query statement in XI
while connection with database through JDBC adapter
E.g For fetching the vendor data from database
Select * from ....</i>
your question a is same. You can execute a SQL statement in the Adapter which polls the database in the intervals you mention. It could be a SELECT or EXEC PROC etc.
regards
Shravan -
Interacting with Powershell from Java
Hi,
I'm trying to run a Java application which creates a new powershell process on startup and then later on interacts with it multiple times. Calling powershell.exe and have it execute a single command and return the output works fine for me. The problem arises if I don't want the powershell process to immediately finish/exit but to stay open so I can write to its outputStream and receive results back from the inputStream.
String input = "dir";
String[] commandList = {"powershell.exe", "-Command", "dir"};
ProcessBuilder pb = new ProcessBuilder(commandList);
Process p = pb.start();
if(input != null) {
PrintWriter writer = new PrintWriter(new OutputStreamWriter(new BufferedOutputStream(p.getOutputStream())), true);
writer.println(input);
writer.flush();
writer.close();
//p.getOutputStream().close();
Gobbler outGobbler = new Gobbler(p.getInputStream());
Gobbler errGobbler = new Gobbler(p.getErrorStream());
Thread outThread = new Thread(outGobbler);
Thread errThread = new Thread(errGobbler);
outThread.start();
errThread.start();
System.out.println("Waiting for the Gobbler threads to join...");
outThread.join();
errThread.join();
System.out.println("Waiting for the process to exit...");
int exitVal = p.waitFor();
System.out.println("\n****************************");
System.out.println("Command: " + "cmd.exe /c dir");
System.out.println("Exit Value = " + exitVal);
List<String> output = outGobbler.getOuput();
input = "";
for(String o: output) {
input += o;
System.out.println("Final Output:");
System.out.println(input);
This code returns the result of the "dir" command from a powershell - fine. But as you can see, I'm trying to run a second "dir" command using
PrintWriter writer = new PrintWriter(new OutputStreamWriter(new BufferedOutputStream(p.getOutputStream())), true);
writer.println(input);
writer.flush();
This has no effect whatsoever - no second dir output is shown when I run my code. I've also experimented with a powershell.exe option to open the powershell but not close it immediately:
String[] commandList = {"powershell.exe", "-NoExit", "-Command", "dir"};
But then my code hangs, meaning the Gobbler's who consume the process's inputStream don't read anything - strangely enough: they don't even read the first line - there must be at least some output....
I've also tried to close the process's outputStream after writing the second "dir" command to it - didn't change anything.
But when I initially call the cmd.exe using the /k (keep open) switch:
String[] commandList = {"cmd.exe", "/k", "dir"};
I can then still write to that outputstream and invoke the second "dir" command and get the output of both "dir" commands from the inputstream fo that process.
Any help is highly appreciated.
Thanks
Kurtuser4491593 wrote:
BUT: my Gobblers only read the output of all my commands Then why don't change your Gobbler code ? ;)
Test this, it's ugly and needs improvemens, but by now works fine on linux and windows:
public class Gobbler implements Runnable {
private PrintStream out;
private String message;
private BufferedReader reader;
public Gobbler(InputStream inputStream, PrintStream out) {
this.reader = new BufferedReader(new InputStreamReader(inputStream));
this.out = out;
this.message = ( null != message ) ? message : "";
public void run() {
String line;
try {
while (null != (line = this.reader.readLine())) {
out.println(message + line);
this.reader.close();
} catch (IOException e) {
System.err.println("ERROR: " + e.getMessage());
public class PowerConsole {
private ProcessBuilder pb;
Process p;
boolean closed = false;
PrintWriter writer;
PowerConsole(String[] commandList) {
pb = new ProcessBuilder(commandList);
try {
p = pb.start();
} catch (IOException ex) {
throw new RuntimeException("Cannot execute PowerShell.exe", ex);
writer = new PrintWriter(new OutputStreamWriter(new BufferedOutputStream(p.getOutputStream())), true);
Gobbler outGobbler = new Gobbler(p.getInputStream(), System.out);
Gobbler errGobbler = new Gobbler(p.getErrorStream(), System.out);
Thread outThread = new Thread(outGobbler);
Thread errThread = new Thread(errGobbler);
outThread.start();
errThread.start();
public void execute(String command) {
if (!closed) {
writer.println(command);
writer.flush();
} else {
throw new IllegalStateException("Power console has ben closed.");
public void close() {
try {
execute("exit");
p.waitFor();
} catch (InterruptedException ex) {
public static void main(String[] args) throws IOException, InterruptedException {
/* PowerConsole pc = new PowerConsole(new String[]{"/bin/bash"});
PowerConsole pc = new PowerConsole(new String[]{"/bin/bash"});
pc.execute("pwd");
pc.execute("ls");
pc.execute("cd /");
pc.execute("ls -l");
pc.execute("cd ~");
pc.execute("find . -name 'test.*' -print");
pc.close();
// PowerConsole pc = new PowerConsole(new String[]{"cmd.exe"});
PowerConsole pc = new PowerConsole(new String[]{"powershell.exe", "-NoExit", "-Command", "-"});
System.out.println("========== Executing dir");
pc.execute("dir");
System.out.println("========== Executing cd\\");
pc.execute("cd \\"); Thread.sleep(2000);
System.out.println("========== Executing dir");
pc.execute("dir"); Thread.sleep(2000);
System.out.println("========== Executing cd \\temp");
pc.execute("cd \\temp"); Thread.sleep(2000);
System.out.println("========== Executing dir");
pc.execute("dir"); Thread.sleep(2000);
System.out.println("========== Executing cd \\bubba");
pc.execute("cd \\bubba"); Thread.sleep(2000);
System.out.println("========== Exiting .... bye.");
pc.close();
}I tested this and there is still a little problem -look at the test below.
It seems that when thecommand
executed in the powershell prints only a one ot two lines,
powershell doesn't flush the output stream
.... but this rather problem of powershell, not the java code
I have not a clue how to force powershell to flush
it's output stream after each command.
C:\temp>java -jar PowerShell.jar
========== Executing dir
Directory: Microsoft.PowerShell.Core\FileSystem::C:\temp
Mode LastWriteTime Length Name
-a--- 2012-01-09 01:16 5290 PowerShell.jar
========== Executing cd\
========== Executing dir
Directory: Microsoft.PowerShell.Core\FileSystem::C:\
Mode LastWriteTime Length Name
d---- 2012-01-08 02:56 61587b977687a6e22fbe
d---- 2011-12-14 03:19 Documents and Settings
d---- 2011-12-15 00:05 oraclexe
d-r-- 2012-01-08 03:44 Program Files
d---- 2012-01-05 19:59 sqldeveloper
d---- 2012-01-09 01:15 temp
d---- 2012-01-09 01:13 WINDOWS
-a--- 2011-12-14 03:12 0 AUTOEXEC.BAT
-a--- 2011-12-14 03:12 0 CONFIG.SYS
========== Executing cd \temp
========== Executing dir
Directory: Microsoft.PowerShell.Core\FileSystem::C:\temp
Mode LastWriteTime Length Name
-a--- 2012-01-09 01:16 5290 PowerShell.jar
========== Executing cd \bubba
Set-Location : Cannot find path 'C:\bubba' because it does not exist.
At line:1 char:3
+ cd <<<< \bubba
========== Exiting .... bye.
C:\temp> -
ALBPM interaction with WS-Policy web services
Can ALBPM integrate with ws-policy web services out of the box? If not, what would be the recommended process to handle this situation?
Hi,
yes, I think to remember that there is support for a single style only. If you need another one too then you create a new project.
Frank -
Move ASM disks with database from one server to another?
I have a 11.2.0 ASM with a 11.2.0 database on two internal disks on server1. The disks are not in any raid or volume manager configuration, i.e. they are just two disks. The disks were physically removed from server1 and installed on server2, which is the same hardware, OS, patch level etc, in the same target position. Installed the 11.2.0 rdbms and grid infrastructure binaries on server2; changed the raw disk partition ownership to oracle and started asmca. asmca does not see the disks.
My question, is this possible and if so, what am I missing?I did not manually create an ASM instance and try to add the diskgoup. My understanding is, if you use asmca then it starts an ASM instance, if one is not already running, and lets you configure your diskgroup. This is what I am trying to do, with no luck (asmca does not see the disks)I may be totally wrong here but afaik dbca creates the ASM instance. ASMCA is just for adding disks or diskgroups......
Did you try to create an ASM instance with dbca? When doing so do not put your disks in there - this will create a new disk group.....
Ronny Egner
My Blog: http://blog.ronnyegner-consulting.de -
Problems connecting with database from java API
I've benn using XSQLRequest and I found a problem with
connections, because it can't connect from Java to database, but
if I access to a .xsql it works.
And also if I link to a .xsql first and after that I try to
access to Database form my servlet it works. So I think my
problem is to initialize the XSQLConfig.xml file in OC4J server.
Thanks in advanceWould you provide the way you deploy your XSQL app to OC4J and
how you get JDBC connection using JAVA? I execute the next code more or less:
miXSQLRequest = new XSQLRequest(XSQLQuery.getDOM
(),null);
miXSQLRequest.process(htParamsIn, pWriter, pErrors);
but and it's probabily my mistake I don't get any conecction
from the session or something similar because I thought that
it's made by XSQLRequest, and the XSQLRequest class takes the
default values of the connection pool from the file
XSQLConfig.xml (I put this file inside the lib directory of
OC4J) as the XSQLServlet.
Thanks for your help -
OSX or Logitech driver incompatibility with sounds from web
If sound comes from certain websites,
OSX (or Logitech driver) have a problem outputting it to the proper port.
I sent feedback to Apple,
but I wonder if anyone else has experienced this or have any comments?
Giovanni
====== DETAILS========
For sounds from certain websites,
If headset is connected to USB port,
SystemPreferences>Sound>Output
does not honor "Line Out" user's selection.
Problem steps:
1) Connect:
Speakers ("Line out") to Built in audio port
Logitech USB Headset to USB port
2) Verify
AppleMenu>SystemPreferences>Sound>Output is set to "Line Out"
3) Play sound using some applications and websites
(for example iTunes, Skipe, http://www.apple.com, etc)
Verify sound comes out of speakers as expected
and SystemPreferences>Sound>Output's
Mute or Output Volume settings respond as expected.
So all hardware works.
4) Play sound from other websites
(for example http://antoniocarlosjobim.brazilmaxmusic.com)
Verify sound mistakenly comes out of Headset.
(and SystemPreferences>Sound>Output
does not respond to Mute or Output Volume changes).
5) Issue is the same for many browsers (Safari, FIre Fox, IE).
Thus, it is not a browser issue.
It happens for sounds from movie or music files.
Thus, it is no a specific file format issue.
It seems likely a Logitech driver/OSX issue
(or we can always blame the websites)
System: iMac 20" 1.8 GHz G5
Mac OS X 10.4.6
Software Update: Your Software is up to date.
iMac G5 Mac OS X (10.4.6) Logitech USB Headset Version: 10.13Yes, ideally all websites would follow W3C standards.
But many don't.
Until then, as you suggest, we should:
1) send a note to the site informing that they should test on both Platforms and
not following standards hurts them before a growing base of users.
As Mac's market share increases (as it is positioned to do),
web masters will get better at testing their sites on both Platforms, and
glitches like this are less and less likely to occur.
But it is not enough to blame the website and
expect the consumer to pick a fight with all non-compliant web masters
(I can't imagine my dad, or the majority or non-technical people, doing this).
That would let the consumer have bad user experience that wastes everyone's time.
This is not "it just works", and ultimately hurts Apple's reputation for most consumers.
In cases like this, I believe it is also important to:
2) send a note to Apple so they are aware of the glitch and can write more robust driver
to handle non-compliant sites gracefully like Logitech did.
This will give "it just works" user experience.
Mac is vastly superior to Windows in nearly every respect and already handles most non-compliant situations great.
This is a really a minor issue (but real, so ball is also on Apple's court to look at).
3) acknowledge the glitch, so we all aware of the facts.
That way Apple will look at fixing it and
consumers will have a workaround (use the headset)
and know it is a known issue they don't need to waste time and aggravation investigating.
In summary, until apple fixes the driver, send note to website and use headset. -
Custom Webpage with data from Web JetAdmin
We are currently using Web JetAdmin to monitor a large fleet of network printers spread across our campus. I love the features of the application but I would like to see if there is a way to simplify the interface a little bit. I would like to see if it is possible to create a custom webpage with the status images of the printers that Web JetAdmin provides on the application interface. Essentially what I would like to do is create a grid of these images for each printer so we could constantly monitor the status of these printers.
Any ideas how I could do this?
Thanks
-Jessehi there,
U can copy that data into a excell file in a fixed format. After that using SQL*Loader u can import that data into oracle database.
But fix one format so that u can easily dump that data into oracle database when ever u want with out much effort.
Cheers
Naveen -
Efficient access to database from web services
Hi
I'm implementing a web service interface to a database. The interface allows its clients to perform a series of independent operations which change some values in a database. Each of these operations is an independent web service, but all of them use the same database.
My first approach was to make each service completely self-contained, and have it create its own JDBC connection to access the database. However this doesn't sound very efficient.
I mean, isn't the application server there precisely to provide these types of services to the applications it hosts? So, is it possible to have it manage a pool of connections of some kind and make the web services get their connections from that pool?
Thanks in advance
PedroHi Cemal,
Try the following.
IWDClientUser user = WDClientUser.getCurrentUser();
user.getSAPUser().getUniqueName();
Please check old postings in the forum.
Regards, Anilkumar -
Hi nid help with database and web
hi to all! i wanted to get some help on how to connect to a database in a web... i dont know if its javascript,java applet,or jsp... could some1 pls give me a code on how to make a simple login database connection in a web through java.. i really nid it guys... we have our contest next week... pls.. i really nid your help... tnx!
hi to all! i wanted to get some help on how to
connect to a database in a web... what do you know about databases and the web today?
i dont know if its
javascript,java applet,or jsp... yes.
could some1 pls give
me a code on how to make a simple login database
connection in a web through java.. (1) create a table USER in your favorite relational
database - id, username, and password should be
enough.
(2) Use HTML to create a login form - username and
password text fields and a submit button will be
good.
(3) Write a JSP using JSTL <sql> tags to query the
database and put the result into request scope.
(4) Redirect to a success JSP to demonstrate a
successful login, or back to the login if it fails.
i really nid itI hope this helps.
guys... we have our contest next week... pls.. i
really nid your help... tnx!What do "we" win? Will you be listing me as the sole
developer if I write this for you?
My rate is $120 USD per hour. Give a credit card
number and I'll get right on it.<Actually its just a contest for our intramurals.. i was just hoping if u guys could help me ... thnx!
Maybe you are looking for
-
Is there a way to use Illustrator to draw over a live video feed coming from my microscope?
Hi, we use illustrator to draw (trace) over static images of mite specimens taken under a microscope. Although this works, it would be much better to be able to draw directly from the live video feed coming from my microscope. The specimens are dead,
-
How do I permanently save changes to photos?
The IOS 7 photo edit allows me to revert to the original photos after edits, which would be ok, if it didn't use the original when interfacing with other apps or when sending. For example, I cropped a lot of photos and then accessed the photos with m
-
Outlook 2007: unable to automatically refresh calendar
Hello, With Outlook 2007 and OCFO 10.1.3.10 we can't get outlook to automatically refresh the calendar view so that events inserted in another client (i.e. same user on the web client or on the native ocal client, or another user) are seen. Tools->Re
-
Debugging a PL/SQL with Oracle SQL Developer
I am trying to debug pl in Oracle SQL Developer, have looked in http://www.oracle.com/technology/obe/11gr2_db_prod/appdev/sqldev/plsql_debug/plsql_debug_otn.htm#t5 and there are not enabled the options "Data", "Smart Data", etc someone knows why? tha
-
Bug editing report attributes in Firefox
Has anybody logged this problem before? It occurs in Apex 2.2 and 3.0 and FireFox 2.2, but I cannot reproduce it using IE6. Open a page with a report region and go to the report attributes. Look at the Headings Type and remember the setting. Edit one