Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
package jdbc;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
public class JDBCTest2 {
public static void main(String[] args) {
dodajKorisnika(1300, "Milos", "Zivadinovic");
private static void dodajKorisnika(int i, String milos, String zivadinovic) {
String url = "jdbc:oracle:thin:@localhost:1521:XE";
String upit = "insert into korisnik values (?,?,?)";
try {
Connection conn = DriverManager.getConnection(url, "system", "manager");
PreparedStatement stat = conn.prepareStatement(upit);
stat.setInt(1, i);
stat.setString(2, milos);
stat.setString(3, zivadinovic);
int count = stat.executeUpdate();
if(count > 0) {
} else {
} catch (SQLException ex) {
Logger.getLogger(JDBCTest2.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.