I am trying to learn to connect a database to a Java program and I encounter an issue that all the entries I provided from my Oracle client are not showing up in my JDBC program
import java.sql.*;
public class jdbc {
public static void main(String[] args) {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con =DriverManager.getConnection("jdbc:oracle:thin:@LAPTOP-PCVGGS4F:1521:xe", "system", "---");
String q = "select * from example";
Statement stmt =con.createStatement();
ResultSet set = stmt.executeQuery(q);
while (set.next()) {
String temp =set.getString(1);
System.out.println(temp);
}
// String q = "insert into example values('Input from jdbc')";
// PreparedStatement stmt = con.prepareStatement(q);
// stmt.executeUpdate();
}
catch (Exception e) {
e.printStackTrace();
}
}
}