Not really sure what you're exactly trying to do but
you can always just concatenate the string using your
arguments.
i.e.
....
resultSet = stmnt.executeQuery("Select * from " +
tableName + " where log_field1 = '" + value + "'");
....
-Mike
--- Ryan Johnson <[EMAIL PROTECTED]> wrote:
>
>
> I have been able to successfuly connect to my Oracle
> Database using
> the JDBC but my select statement that I have used so
> far is static
> and I would like to make it dynamic and pass a value
> to it. Can
> anyone help me out and tell me how I can do this?
>
> Here's a little portion of the code. I want to pass
> a value in place
> of the log_field5 in the select statement.
>
> public class tledatabase{
> public static void main(String [] args){
> tledatabase thisTest = new tledatabase();
> thisTest.test();
> }
> public void tledatabase(){}
>
> public void test(){
> System.out.println("about to connect");
> connect();
> System.out.println("Connection complete");
> }
>
>
> public void connect(){
> Connection conn = null;
> try {
>
> Class.forName("oracle.jdbc.driver.OracleDriver");
>
> conn = DriverManager.getConnection
> ("jdbc:oracle:thin:@0.0.0.0:1521:DATA", "user",
> "password");
> if (conn!=null){
> System.out.println("connection
> made");
> Statement stmt = null;
> ResultSet rset = null;
>
> stmt = conn.createStatement();
>
> // Execute Statement to get
> product Information
> from the Database
> rset = stmt.executeQuery(" SELECT
> log_field1 " +
> " FROM " + "transaction0 where
> log_field5
> = '596612'");
>
> while (rset.next())
> System.out.println(rset.getString
> ("log_field1"));
>
> // Close Result Set and
> Statement
> rset.close();
> stmt.close();
>
>
>
>
>
>
>
>
__________________________________
Do you Yahoo!?
Check out the new Yahoo! Front Page.
www.yahoo.com
------------------------ Yahoo! Groups Sponsor --------------------~-->
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/5cFolB/TM
--------------------------------------------------------------------~->
If you have any comments or questions, submit it on the message board.
NO spam/ads/job posting or you will be BANNED from this group. Exception can be
made it happen by notify me ahead of time.
all new members' message will be verified by me (spam..) before it get posted.
Yahoo! Groups Links
<*> To reply to this message, go to:
http://groups.yahoo.com/group/java_official/post?act=reply&messageNum=17402
Please do not reply to this message via email. More information here:
http://help.yahoo.com/help/us/groups/messages/messages-23.html
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/java_official/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/