Set target fileds from source fields using JDBC lookUp
hello :
advance thanks for reading below and i am new to java
how to to set the two taget fileds T1 and T2 from source field S1 using jdbc look up .Here is the code and its giving syntax error . set T1 to approver1 and T2 to approver2
I copied the code from blog 2219
How to map to two target fileds ??
Is something wrong with the query ?
/people/siva.maranani/blog/2005/08/23/lookup146s-in-xi-made-simpler
>>>>>>>>I defined Argument a(i am passing S1) Result result
>>>Here is the code :
//write your code here
String Query = " ";
Channel channel = null;
DataBaseAccessor accessor = null;
DataBaseResult resultSet = null;
// Build the Query String
Query = "Select (approver1,approver2) from Emp where loginid = ' " + a[0] + " ' '';
try{
//Determine a channel, as created in the Configuration
channel = LookupService.getChannel("SQL99","jdbc_cc1");
//Get a system accessor for the channel. As the call is being made to an DB, an //DatabaseAccessor is obtained.
accessor = LookupService.getDataBaseAccessor(channel);
//Execute Query and get the values in resultset
resultSet = accessor.execute(Query);
for(Iterator rows = resultSet.getRows();rows.hasNext();){
Map rowMap = (Map)rows.next();
result.addValue((String)rowMap.get("(approver1"));
//result.addValue((String)rowMap.get("approver2"));
catch(Exception ex){
result.addValue(ex.getMessage())
finally{
try{
if (accessor!=null) accessor.close();
catch(Exception e){
result.addValue(e.getMessage())
thankyou sdn:
hi kumar,
every statment in java should end with a semicolon... and 2 catch statments in the code given in blog(that you mentioned) are with missing semicolons at the end of the statments... just include semicolons at the end of these 2 catch staments and your code should work properly without any syntax error...
catch(Exception ex){
result.addValue(ex.getMessage());
finally{
try{
if (accessor!=null) accessor.close();
catch(Exception e){
result.addValue(e.getMessage());
Regards,
JP
Similar Messages
-
How to set the target directory from source filename using adaptor module.
Hi,
How im using a logical bypass scenario.I have to set the target directory using the sorce filename.There is no chance of using a Java UDF as my scenario does not have a Mapping(as it is a Bypass Scenario).The only option that i got is to use a Adaptor module.Can anyone help me this.
Thanks,
BhargavHi,
See this link,
http://help.sap.com/saphelp_nw04/helpdata/en/e9/61e1407e858031e10000000a1550b0/content.htm
hope it helps.
Regards,
Akshay Jamgaonkar.
Reward points if find useful. -
How to remove target node if source field value is empty SAP PI Mapping
Hello,
how to remove target node if source field value is empty in graphical Mapping.
Like if
MIddle name in source filed is empty, I would like to eliminate target field from out put XML.
Thank you
JohnHi Jhon,
If you want to remove all empty tags and you dont to complicate your message mapping, you can use a XSL, after the message mapping, to remove all the empty tags:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*[not(@*|*|comment()|processing-instruction())
and normalize-space()='' ]"/>
</xsl:stylesheet>
Regards -
Can we set the dynamic data source when using getReportParameters() ?
Hello!
I have a report where one of its parameters refers to a list of values (LOVs). This list of values is an SQL Query type. When the data source used in the report is defined in the BI Publisher server, I'm able to get the report parameters using the getReportParameters() function in my application. However, if the data source is not defined the function throws an exception, which is understandable.
I decided to dynamically set the data source so that even if the data source used by the report is not defined in the BI Publisher server, it still will be able to get the LOVs for the parameter. I tried setting the JDBCDataSource of the dynamicDataSource for the ReportRequest object that I passed to the getReportParameters() function. Please see the sample code below:
reportRequest.dynamicDataSource = new BIP10.BIPDataSource();
reportRequest.dynamicDataSource.JDBCDataSource = new BIP10.JDBCDataSource();
setReportDataSource(reportRequest.dynamicDataSource.JDBCDataSource, connectstr, jdbc, dc); //function to set the values for JDBCDataSource object
reportParams = webrs.getReportParameters(reportRequest, uid, pwd); //call the getReportParameters
I was expecting this to work as this is what I did to dynamically set the data source before calling the runReport function. So, my question is -- can we set the dynamic data source when using getReportParameters() ? I tried this both in versions 10g and 11g. It does not seem to work on both versions.
Regards,
Stephaniereport_id column of apex_application_page_ir_rpt can help us uniquely identify each saved report.
We can assign this report_id value to a page item and this page item can be put in the Report ID Item text box of the Advanced section of the Report Attributes page of the IR.
This should load the saved report identified by report_id and you can get rid of javascript
Regards,
Vishal
http://obiee-oracledb.blogspot.com
http://www.packtpub.com/oracle-apex-4-2-reporting/book
Kindly mark the reply as helpful/correct if it solves your problem -
Is there a way to exclude files from source paths using patterns
Hi
Does anyone know of any way to exclude files from source paths using patters rather than individually selecting the files? UI doesn't allow to specify any pattern. But if you look at the jpr file there are other places where patterns are allowed. Can the same pattern be copied and applied to excluded files?
PatDrag the files, or press Option when pasting them; this accesses the Move To function.
(124070) -
Retrieving data from Microsoft Access using JDBC
I noticed that when i tried retrieving data from Microsoft access using JDBC, I realised that it was throwing SQLException when the column names were two word with spaces between them, e.g. Date Birth. But after i removed the space from the column names, my SQL queries were retrieving data. Was it because of the space in between the column names of the table?
Yeah, as far as I know having two word column names isn't allowed in SQL. There might be some way to escape it, but generally it's sensible to avoid it.
-
How to use JDBC Lookup in PI 7.1 ?
Hi,
Please advise how to use JDBC lookup in message mapping PI 7.1 ? any reference link / document ?
I have followed this step below :
1. Create the external definition for the database table.
2. Use the external definition (table) in message mapping JDBC Lookup.
But the target still "Yellow colour" meanint the mapping hasnot completed yet ? why ? and when i double click the JDBC lookup
there some error message
"No suitable parameter found; define new parameter of type 'Channel' first"
Please advise.
Thank You and Best Regards
FernandHi Fernand,
JDBC Lookup can be done in PI 7.1 using below mentioned steps :
1) Create a communication channel between PI and the database to connect to database.
2) Import the table data as External Definition.
3) In message mapping where this lookup is to be used select JDBC Lookup under Conversions and map
4) Double Click on JDBC Lookup
5) Select parameter and a database table (imported as the external definition). All the elements of the table will appear in the middle column. Select and move the input parameters to the left side column and the output parameters to the right side column. Click OK.
6) Under message mapping go to signature tab and define the parameter as channel and category as JDBC Adapter Type.
7) Under Operation mapping define the parameter & associate it with parameter defined in Message Mapping.
Thanks
Amit -
Empty CLOB field value from Oracle database using JDBC Sender
Hi All,
I am selecting a CLOB field from Oracle database table using JDBC Sender adapter and getting error "NullPointerException"
Seen SAP note 1283089 but its not applicable for my support pack PI 7.0 SP 12 and client dont want to upgrdate SP 17 right now.
I tried rpad(1,0)Column_Name funciton in JDBC select query but it selcting blank value for every record even those having some value for this CLOB field so not useful
Could anybody suggest possible way? client dont want to change anything at database side.
Thanks,
DharamveerWhat is the Oracle driver version installed? You might need to install 10.x driver if not already using it.
-
Determine Target directory from Source file names with out mapping
Hi All,
I have a requirement to determine the Target Directories from the Source file names.
File Sender Adapter - XI - File Receiver Adapter
In this scenario I am not doing any mapping. Source File directory contain 3 files. These file should go to 3 directories in the Target Server.
Please help me how can meet this requirement
Thanks in advance
KevinHi Kevin,
if you can separate the files by name. have 3 sender communication channels each picking up one of the files (you do this by making the regex in the file name mutually exclusive) and then send them all to the target system using the same comm. channel.
regards,
Horia -
Search help from one field used to populate another on subscreen.
I have a subscreen with 2 fields; Plant & Batch. Search help MCH1F displays batches for plants. When a batch for a plant is selected in the search help for the batch field, I want to populate the plant field in addition to the batch. The batch number comes back from the search help selection, but I need to get the plant associated with that batch just selected and populate the subscreen plant field. SET/GET doesn't work either in the screen field setup or abap flow logic. Any tips would be appreciated. Thanks.
Hi Kurt,
i think that way its not possible but the closest way is
i HAVE TWO TABLES
ZPHY
ZPROC
I HAVE SCREEN IN WHICH I HAVE TO GET VALUE FOR PHY BASED ON ID.
AND FOR OTHER FIELD IN THE SCREEN I HAVE PROC BASED ON THE ID I USED TO GET PHY AND FOR THE SAME ID I AHVE MULTIPLE PROC AND I HAVE SELECT ONE OF THOSE , HERE WHEN YOU PRESS F4 IT WILL GIVE ALL THE PROC ASSOCIATED TO
ID THATI USED IN THE SELECTION OF PHY.
AND I THINK YOURS IS THE SAME CASE RIGHT.
FIRST GET
process on value-request.
FIELD zabc-def MODULE VALUE_REQUEST_PHYACT.
FIELD zabc-proc MODULE VALUE_REQUEST_PROC.
MODULE VALUE_REQUEST_PHYACT INPUT.
DATA: progname TYPE sy-repid,
dynnum TYPE sy-dynnr.
CLEAR zabc.
CLEAR : zabc-def, zabc-id, zabc-proc,
zabc-ZSHECPROC.
CLEAR FINAL.
CALL FUNCTION 'F4IF_FIELD_VALUE_REQUEST'
EXPORTING
TABNAME = 'ZPHY'
FIELDNAME = 'def'
SEARCHHELP = 'ZPHY'
SHLPPARAM = ' '
DYNPPROG = PROGNAME
DYNPNR = DYNNUM
DYNPROFIELD = ' '
STEPL = 0
VALUE = ' '
MULTIPLE_CHOICE = ' '
DISPLAY = ' '
SUPPRESS_RECORDLIST = ' '
CALLBACK_PROGRAM = ' '
CALLBACK_FORM = ' '
TABLES
RETURN_TAB = IT_RETURN4
EXCEPTIONS
FIELD_NOT_FOUND = 1
NO_HELP_FOR_FIELD = 2
INCONSISTENT_HELP = 3
NO_VALUES_FOUND = 4
OTHERS = 5
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
read table it_return4 index 1.
zabc-def = it_return4-fieldval.
select single id into zabc-id FROM ZPHY
WHERE def = zabc-def.
FINAL-def = zabc-def.
FINAL-id = zabc-id.
HERE BASED ON ID I AM RETRIEVING DEF FIELD ,THIS IS FROM SEARCH HELP USING SE11.
AND FOR THE SAME ID I HAVE TO GET PROC FIELD FROM ANOTHER TABLE
ENDMODULE. " VALUE_REQUEST_PHYACT INPUT
MODULE VALUE_REQUEST_PROC INPUT.
DATA : SERVICE LIKE zabc-id.
select single id into SERVICE FROM ZPHY
WHERE def = zabc-def.
SELECT * INTO TABLE ITAB_TEST4 FROM ZPROC
WHERE id = SERVICE.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
DDIC_STRUCTURE = ' '
RETFIELD = 'proc'
PVALKEY = ' '
DYNPPROG = ' '
DYNPNR = ' '
DYNPROFIELD = ' '
STEPL = 0
WINDOW_TITLE = 'PROCEDURE'
VALUE = ' '
VALUE_ORG = 'S'
MULTIPLE_CHOICE = ' '
DISPLAY = ' '
CALLBACK_PROGRAM = ' '
CALLBACK_FORM = ' '
TABLES
VALUE_TAB = ITAB_TEST4
FIELD_TAB =
RETURN_TAB = IT_RETURN4
DYNPFLD_MAPPING =
EXCEPTIONS
PARAMETER_ERROR = 1
NO_VALUES_FOUND = 2
OTHERS = 3
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
if sy-subrc = 0.
clear itab_TEST4.
read table it_return4 index 1.
zabc-proc = it_return4-fieldval.
read table itab_TEST4 with key id = itab_details-def
itab_zMOR-def = itab_details-def.
itab_zMOR-zzfname = itab_details-zzfname.
endif.
SELECT SINGLE ZSHECPROC INTO zabc-ZSHECPROC FROM ZPROC
WHERE proc = zabc-proc.
FINAL-proc = zabc-proc.
final-zshecproc = zabc-zshecproc.
*********AGAIN THIS IS NOT THE SEARCH HELP FROM SE11
ENDMODULE. " VALUE_REQUEST_PROC INPUT
hope this helps
Thanks -
Urg:Executing SQL From Java App using Jdbc Driver
Hi
I am using JDBC Driver version 9.0.1.1.0.
I am running this in Thin Client Mode
My Code Snippet Looks Like This:=
==========================================================
String url = "jdbc:oracle:thin:@localhost:1521:VpDb";
String userName = "scott";
String password = "tiger";
Connection conn = null ;
Statement st = null ;
ResultSet rs = null ;
String categoryCode="ABC";
try
conn = DriverManager.getConnection (url, userName, password);
st = conn.createStatement ();
String sqlStatement = "Select Count(*) From News Where CategoryCode=" +"\'" + categoryCode + "\'" + ";";
System.out.println(sqlStatement);
rs = st.executeQuery ( sqlStatement );
if( rs.next() )
System.out.println("Headline Exists");
else
System.out.println("No Headline Exists");
catch (SQLException e )
System.out.println();
System.out.println (" SQL ERROR IN IS_NEWS_EMPTY: " + e) ;
=========================================================
I have added the classes12.zip and nls_charset12.zip in the classpath.
Now when i run this it gives me an error saying the following error message:-
SQL ERROR IN IS_NEWS_EMPTY: java.sql.SQLException: ORA-00911: invalid character
Can anyone help me with this as to whats going wrong because the exact equivalent of my sqlStamenet runs on SQL command line but not from java code.Why??
Any Help appreciated
Thanks
MumI think it is complaining about the ";" that you add at the end of your string. You don't need to add that to the query.
-
Is there a way to retrieve data from database wihout using JDBC while using JPDK?
Hi,
I want to create a portlet using JPDK with extra render modes and edit/Edit defaults mode too. The detail and show renderer mode jsp's/servlets render data from database. Based on the personalized paramter, the data rendered in detail and show mode will be obtained from database.
The articles in the PDK zip asks not to use JDBC for security vulnerability. Does that mean , I should not use JDBC to connect to db to get data. If not, what should I use ? How do I connect to database ? Is there any class which helps to connect to db without using JDBC ?
thanks,
MainakI'm not sure what articles you are refering to, because there is no other way to access a database from a java program. Generally, security related docs tend to be a little paranoid (and so they should be), but you have to balance high security against getting the job done.
Obviously, if using JDBC, you need to be careful about protecting your config files because they will contain connection information. -
Retrieving Schema details from any database using JDBC.
Hi,
We are in a process of developing a tool to extract the schema level details from any database. Following are the areas where we are facing difficulties. Please give us your valuable comments.
1.How can I get all the depending views of a particular table or vice- versa ?
2.If there is a join view in my database.How can i get the information
for all the join columns?
3. suppose the view in the database is built using some select and omit
Clause. how can I get those conditions using JDBC ?
4.for a viewcolumn , how can I find out, it refers to which column of
a table ?
5.For a table how can I get the information about its unique
constraints and check constraints
6.How can I check , a constraint is enabled or disabled on any table?
I will appreciate your response.Hi,
We are in a process of developing a tool to extract
ct the schema level details from any database.
Following are the areas where we are facing
difficulties. Please give us your valuable comments.
1.How can I get all the depending views of a
particular table or vice- versa ?No way with JDBC. You need to create something DBMS specific
2.If there is a join view in my database.How can i get
the information for all the join columns?see 1)
3. suppose the view in the database is built using
some select and omit
Clause. how can I get those conditions using JDBC
BC ?see 1)
4.for a viewcolumn , how can I find out, it refers to
which column of a table ?see 1)
5.For a table how can I get the information about its
unique constraints and check constraintsThe DatabaseMetadata object can return that information
6.How can I check , a constraint is enabled or
disabled on any table?I don't think that this is possible with JDBC (not sure
if that information is returned from the DatabaseMetadata
object). You will need to code something DBMS specific
I think there is something with deferred constraints which
can be checked by JDBC but I'm not sure about that either
Thomas -
Problem connecting to SQL Server from JDeveloper 10g using jdbc third party
I am using Oracle 10g Jdeveloper and I tried to setup a database
connection to SQL Server using various Drivers for JDBC as Merlin, jtds, inet.tds, etc.
(I had no problem to set up a connection to an Oracle Database using the
Oracle JDBC driver).
When I am testing the connection throughout the wizard, I do receive
this error message: "Unable to find driver:
com.microsoft.jdbc.sqlserver.SQLServerDriver".
I m not understanding from last 3 days where to place the corresponding JAR files so thaI may not get the Error.
When I hit n trialed at various directories of the JDeveloper as </rootDir/jdbc/lib>
</rootDir/lib>
</root/jdev/my Work/Application1/Project1/public_html>
</root/jdev/my Work/Application1/Project1/public_html/web-inf/>
when I tested the connection I do received:
"Unable to find driver:
xxx.xxx.xxx.xxxxxxx Unable to find driver:
Obviously it can't locate the Micrososft JDBC driver but I can't
figure out why.
I tried all kind of things without any success. Is somebody can help
me and took me beyond this.
I m trying to build DataSource connection from JavaBeans.
Please make me out of this cave. I m not finding any of the way to do this.
The last code I tried is
try {
Class.forName("com.inet.pool.PoolDriver");
com.inet.tds.TdsDataSource tds = new com.inet.tds.TdsDataSource();
tds.setServerName( "local" );
tds.setDatabaseName( "bluff" );
tds.setUser( dbUserName );
tds.setPassword( dbPassword );
DataSource ds = tds;
Connection con = ds.getConnection(dbUserName,dbPassword);
Statement stmt;
ResultSet rs = null;
Thanks,you are confusing me at least as your error is discussing the microsoft driver yet you are configuring the inet datasource.
I do not use JDeveloper, but you need to make sure that whatever is servicing your web app/JavaBean has access to the driver. Not sure why you are not doing a JNDI look up of the resoure, but because you are not you can stick the driver jar in the lib directory within the WAR bundle. I would suggest that you add the driver to the lib/ext or the lib directory which is loaded at boot time for your web container and then use JNDI to look up your DataSource to reduce your coding maintenance headaches. -
Geting and setting date and time in oracle using jdbc
can u send me a sample snippet which shows me how to set date and time to a column in oracle database where the column datatype is date.
and also send me the sample code to get the date and time from the above said column
thanks in advanceIf you want DATE with time normalized to midnight, use java.sql.Date. If you really want time, with hours/minutes/seconds/millis, use java.sql.Timestamp.
As for the best way to interact with the database, use java.sql.PreparedStatement and its get/setDate and get/setTimestamp methods. Those will escape dates for you properly.
Look for a JDBC tutorial on-line to see how to do this, or http://www.javaalmanac.com for the java.sql package examples.
%
Maybe you are looking for
-
New Camera Roll backup/restore issue...
Hello, I have a massive problem and cannot find an answer to this anywhere....so, i'm hoping someone here can help. (I'm not great with computers!) I upgraded from iphone4 to 4S in February. I set-up with icloud, but turned off both the Camera Roll a
-
HiI'm trying to use USC-216 Isolated USB to SPI Converter with Labview.But I can't communicate with the unit Is someone familiar with this converter?Best regardsGuy Solved! Go to Solution.
-
Downscaling a movie from 1080 to 720 the best way in Final Cut Pro?
Which way is best to achieve the best quality in this procedure? I was hoping to be able to do this using the Final Cut Pro application, hopefully not the compressor or any other application if possible.
-
Can you disable the mac's start-up sound?
Thanks in advance for any help.
-
Converting excel file to PDF using Adobe 9 standard on windows XP
I have installed office 2010 SP1 on a computer and it already has adobe 9 installed. user never had problem with converting multi sheet excel workbook to PDF using MSoffice 2003. Now, when we open excel files in EXCEL 2010 then try to print it to ado