• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to execute sqlplus and sql commands using java

 
anilellendula kumar
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,



Example
1)col table_name heading "Table|Name"
col column_name heading "Column|Name" format a25
select table_name,column_name from all_tab_columns
where rownum<11;

Example
2)column count format 99999999 heading "No. of|Rows"
select count(*) "count" from user_tables;



above two statements are having sqlplus command and sql command , These sqlplus and sql command i will pass through the TextArea to the Next Page , Next Page Having JDBC program it has to give result of these command ,How to code using java .
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm. The SQL is no problem - you just let JDBC pass that to the database and handle the results. The SQLPlus commands however are a different matter. Its SQLPlus, not Oracle that interprets them so you'd have to ape that behaviour in your GUI application. So I'd imagine something like a lot of regular expressions to parse the incoming SQL/SQLPlus mix, extract out the SQLPlus stuff, query the database then format the results based on the SQLPlus commands. Not nice.
 
anilellendula kumar
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
col table_name heading "Table|Name"
col column_name heading "Column|Name" format a25
select table_name,column_name from all_tab_columns
where rownum<11;

this sql and sqlplus command kept in TextFile, i want to call this textfile using java and connect to the database using JDBC can u help me the code of the JDBC to get the result of sql and sqlplus commands textfile
--------------------------------------------------------------------------------
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You wouldn't be able to access something that Oracle specific. Maybe you could keep the command somewhere else?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic