on 02-21-2006 7:41 PM
Hi all,
I have build a webdynpro with a editview. I want to save the date in to a SQL table. The column in the table has the data type Long. Can someone give me a sample how to convert the text of the editview in to a Long data type.
Kind regards,
Richard
Hi Sebastian,
The JDBC connection is running correctly. My application is saving the rest of the values correctly in the table of the database. It is more that I can not save data from a textEdit to a field in the table. In the Webdynpro I have to use a String and I the database need to use a Float data type because of the more than thousend character.
This is the first time that I have to save multiple lines into a table field.
Kind Regards,
Richard
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Richard,
but in the case your db does not accept the value there must be a SQLException or something like that. Also make sure that the db can convert the value to float:
// remove all n
s = s.replaceAll("\n", "");
// remove all whitespaces
s = s.replaceAll(" ", "");
If that not solves your issue, please post the value of your String and your insert statement.
Sebastian
Richard,
but in the case your db does not accept the value there must be a SQLException or something like that. Also make sure that the db can convert the value to float:
// remove all n
s = s.replaceAll("\n", "");
// remove all whitespaces
s = s.replaceAll(" ", "");
If that not solves your issue, please post the value of your String and your insert statement.
Sebastian
Richard,
but in the case your db does not accept the value there must be a SQLException or something like that. Also make sure that the db can convert the value to float:
// remove all n
s = s.replaceAll("\n", "");
// remove all whitespaces
s = s.replaceAll(" ", "");
If that not solves your issue, please post the value of your String and your insert statement.
Sebastian
Richard,
but in the case your db does not accept the value there must be a SQLException or something like that. Also make sure that the db can convert the value to float:
// remove all n
s = s.replaceAll("\n", "");
// remove all whitespaces
s = s.replaceAll(" ", "");
If that not solves your issue, please post the value of your String and your insert statement.
Sebastian
Richard,
but in the case your db does not accept the value there must be a SQLException or something like that. Also make sure that the db can convert the value to float:
// remove all n
s = s.replaceAll("\n", "");
// remove all whitespaces
s = s.replaceAll(" ", "");
If that not solves your issue, please post the value of your String and your insert statement.
Sebastian
Richard,
but in the case your db does not accept the value there must be a SQLException or something like that. Also make sure that the db can convert the value to float:
// remove all n
s = s.replaceAll("\n", "");
// remove all whitespaces
s = s.replaceAll(" ", "");
If that not solves your issue, please post the value of your String and your insert statement.
Sebastian
The dbms sould convert the string automatically to the type of your table field. But make sure that your string does not contain whitespaces or line breaks.
You can use:
s = s.replaceAll("\n", "");
s = s.replaceAll(" ", "");
If that does not solve your issue, please post the value of the string and your insert statement.
The dbms sould convert the string automatically to the type of your table field. But make sure that your string does not contain whitespaces or line breaks.
You can use:
s = s.replaceAll("\n", "");
s = s.replaceAll(" ", "");
If that does not solve your issue, please post the value of the string and your insert statement.
Hi all,
I tried to implement your source in to my webdynpro. I don't get any error, but data is not saved in the database field.
What could be the error.
Kind regards,
Richard
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Richard,
I dont know if u has problem with getting long values from TextEdit element or with sendingt that to database.
Sample to long values getting:
String text=wdContext.currentContextElement().getText();
// split string from TextEdit
String[] res = text.split("n");
for (int i = 0; i < res.length; i++) {
//convert strings to long
res<i>=res<i>.trim();
try{
long l=Long.parseLong(res<i>);
}catch (Exception e){//report or ignore exceptions}
}
</i>
Db sample is in last post.
I think u should better use PreparedQuery and set values wits setLong methods.
regards
Bogdan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Dharmi,
Sorry I mean a TextEdit. I have save the text in to a sql table. the colomn in the table is a of datatype Long.
Kind Regards,
Richard
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Richard,
Have you deployed the JDBC driver on your J2EE server?
In case you haven't, then that's your starting point.
If you have the jdbc drivers installed, then use the following piece of code to save your TextEdit data:
InitialContext ctx = new InitialContext();
DataSource src = (DataSource) ctx.lookup("jdbc/MSSQL");
Connection sqlCon = src.getConnection();
if(sqlCon != null){
Statement stmnt = sqlCon.createStatement();
stmnt.executeUpdate("INSERT INTO <your table name> (<colName1, colName2...>) VALUES( '" + <your string variable> + "',...)");
}
Regards,
Satyajit.
Hello Richard,
What is editwiew? Do you mean the UI element Textview or TextEdit or something else? Can you please clarify?
Best regards,
Dharmi
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 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.