Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.CallableStatement;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.sql.Types;
- import javax.xml.transform.Result;
- public class TestJava {
- private final String url = "jdbc:postgresql://localhost:5433/dvdrental";
- private final String user = "postgres";
- private final String password = "makary123";
- public Connection connect() throws SQLException {
- return DriverManager.getConnection(url, user, password);
- }
- public void callPro(int id) {
- int inv_id = id;
- int cust_id = 0;
- String name = "";
- try {
- Connection conn = connect();
- CallableStatement cstmt = conn.prepareCall("{? = call print_full_name(?)}");
- cstmt.setInt(2, inv_id);
- cstmt.registerOutParameter(1, Types.VARCHAR);
- cstmt.execute();
- name = cstmt.getString(1);
- System.out.println(name);
- }catch (SQLException e) {
- System.out.println(e.getMessage());
- }
- }
- public TestJava() {
- // TODO Auto-generated constructor stub
- }
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- TestJava t = new TestJava();
- t.callPro(1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement