I new with database and java.I want to show result of the table WHERE USER = USER LOGIN NAME
private void query() {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@andy-lcoyx7gfw:1521:orcl", "andy", "andy");
String sql = "select * from schedules where (userName = @User) ";
//'{$_SESSION['username']}'
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(sql);
ResultSetMetaData md = rs.getMetaData();
int columns = md.getColumnCount();
for (int i = 1; i <= columns; i++) {
columnNames.addElement(md.getColumnName(i));
}
while (rs.next()) {
Vector row = new Vector(columns);
for (int i = 1; i <= columns; i++) {
row.addElement(rs.getObject(i));
}
data.addElement(row);
}
rs.close();
stmt.close();
} catch (Exception e) {
System.out.println(e);
}
}