• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to Match ColumnNames of Database and User entered TextFields

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

My Task is to insert the User Entered Textfield values into DataBase .
To do this actually i should know whether this Textfield belong to a Number or a Varchar2 type (Only These types are there at present) to put a quotion mark for a varchar

I am retreiving all these values into Second JSP Page.

So in MY Second JSP Page i am using this code

I am getting TextField values from another JSP into current Page using


// I am able to get all the values here of the entered Textfields.

ArrayList list = new ArrayList();

String DbQuery = "select DATA_TYPE from user_tab_columns whereTABLE_NAME='POLE_COMMERCIAL'";




(This List of values will bestored in ArrayList as )

NUMBER
VARCHAR2
VARCHAR2
VARCHAR2
DATE
DATE
VARCHAR2


Now please tell me how can i append a ' ' to a character .
I tried this way but its not working



My Ultimate goal would be

INSERT INTO POLE_COMMERCIAL VALUES(233,'Comercial',33,'R');

Anybody please help .
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anybody please .
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, String concatenation works pretty much just as you have it:


However, what you are trying to do is concatenation with an ArrayList, which wont work.

One question, why are you trying to surround the values in your statement with quotes rather than just using a PreparedStatement?

Lastly, you are aware that Java code in a JSP is not considered good practice? Have you though of abstracting this logic into a bean?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!