CAF -- dynamic query against Database

Hi,

I am new on CAF.

Instead of using database connector, which is no much flexible for the query statement. I want to build a dynamic query against Oracle database, and display result in a table on view.

I would like to write a following code in Designer, and binding the result with table in view.

try{
Class.forName(“oracle.jdbc.driver.OracleDriver”);
String url=“jdbc:oracle:thin:@localhost:1521:OracleDB”;
Connection connection = DriverManager.getConnection(url, “user”, password");
Statement stmt=connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
rs=stmt.executeQuery(“SELECT * FROM tbl_Employee”);
}
catch(SQLException e){}
catch(ClassNotFoundException e){}
return rs;
}

Is it a correct approach?

Thanks,

Shuren

I don’t consider hard coding connection parameters into the code as “more flexible”. What are you really trying to accomplish that can’t be done with the db connector?

Mark

Hi Mark,

Thanks your reply.

I just want to write a simple query like “select * from Employee where EmployeeID = ?”

and binding the textbox with input parameter.

Q1:
If textbox is null, query should return all the results. However, if I use above query, the result will be null.

Q2:
How can I add a html control, like a delete button, which can delete the corresponding row. DB connector generates the table, and it’s hard to modify.

Thanks,

Shuren