Created
June 1, 2015 22:43
-
-
Save mzdv/8050d643f38a02bbd150 to your computer and use it in GitHub Desktop.
Get
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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