Skip to content

Instantly share code, notes, and snippets.

@mzdv
Created June 1, 2015 22:42
Show Gist options
  • Save mzdv/bd48bf3624a06171185e to your computer and use it in GitHub Desktop.
Save mzdv/bd48bf3624a06171185e to your computer and use it in GitHub Desktop.
obican
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