Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get
package jdbc;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;
public class JDBCTest1 {
public static void main(String[] args) {
nadjiOdeljenja();
}
private static void nadjiOdeljenja() {
String url = "jdbc:oracle:thin:@localhost:1521:XE";
String upit = "select * from KORISNIK";
try {
Connection conn = DriverManager.getConnection(url, "system", "manager");
Statement stat = conn.createStatement();
ResultSet rs = stat.executeQuery(upit);
while(rs.next()) {
System.out.println(rs.getInt(1));
System.out.println(rs.getInt("id"));
System.out.println(rs.getString(2));
System.out.println(rs.getString("IME"));
System.out.println(rs.getString(3));
System.out.println(rs.getString("prezime"));
}
} catch (SQLException ex) {
Logger.getLogger(JDBCTest1.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.