on 02-17-2011 7:25 PM
Hi,
Can we insert data into a table using jdbc lookup UDF in message mapping .
regards
sandeep
Edited by: pendyalas on Feb 17, 2011 8:25 PM
Edited by: pendyalas on Feb 17, 2011 8:26 PM
Hi,
You can make use the following sample java code to connect to a Sql database table:
Full source code required to establish a JDBC connection to a mSQL database on a server named "www.myserver.com".
import java.sql.*;
/**
* JdbcInsert1.java - Demonstrates how to INSERT data into an SQL
* database using Java JDBC.
*/
class JdbcInsert1 {
public static void main (String[] args) {
try {
// Step 1: Load the JDBC driver.
Class.forName("com.imaginary.sql.msql.MsqlDriver");
// Step 2: Establish the connection to the database.
String url = "jdbc:msql://www.myserver.com:1114/contact_mgr";
Connection conn = DriverManager.getConnection(url,"","");
Statement st = conn.createStatement();
st.executeUpdate("INSERT INTO Customers " +
"VALUES (1001, 'Simpson', 'Mr.', 'Springfield', 2001)");
st.executeUpdate("INSERT INTO Customers " +
"VALUES (1002, 'McBeal', 'Ms.', 'Boston', 2004)");
st.executeUpdate("INSERT INTO Customers " +
"VALUES (1003, 'Flinstone', 'Mr.', 'Bedrock', 2003)");
st.executeUpdate("INSERT INTO Customers " +
"VALUES (1004, 'Cramden', 'Mr.', 'New York', 2001)");
conn.close();
} catch (Exception e) {
System.err.println("Got an exception! ");
System.err.println(e.getMessage());
}
}
}
HOPE IT HELPS YOU BUDDY!!!
Thanks
Biswajit.
Edited by: 007biswa on Feb 18, 2011 11:42 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Insertion is possible using UDFs via Message Mapping..
but it is not advisabel to do so..for e.g if have insert operation in mapping and mapping has been failed after this step and you will try to reececute the same which in turn will get execute the insert operation again and it may fail or may lead to data inconsistencies ..so it is not recommended to do so..
HTH
Rajesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
please refer following blog link:
/people/arpil.gupta/blog/2008/11/03/workaround-for-jdbc-scenarios
Regards,
Deepak.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Inserting the record using jdbc lookup is not possible in the mapping.
You have to write UDF, where you pass the insert values and then write custom jdbc code.
First of all, you need to import the driver and other required jar file. and then you can code to establish connection to the database.
Once you have connection object, you can do any database operation.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Insert using JDBC Graphical Lookup might not be possible. But if you prefer to write UDF you can use
com.sap.aii.mapping.lookup.DataBaseAccessor class and execute method with argument string as your sql statement and check.
Please check this link
/people/alessandro.guarneri/blog/2006/03/27/sap-xi-lookup-api-the-killer
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.