📄 getprice.java
字号:
package procedures;
import java.sql.*;
import connections.*;
import java.util.*;
public class GetPrice {
public static void main(String[] args) {
Connection conn = null;
CallableStatement stmt = null;
try {
conn = ConnectionFactory.getConnection();
String sql = "{ ? = call get_price(?) }";
stmt = conn.prepareCall(sql);
stmt.setInt(2, Integer.parseInt(args[0]));
stmt.registerOutParameter(1, Types.DOUBLE);
stmt.executeUpdate();
//if no exception is thrown, the update succeeded
System.out.println("Price is " + stmt.getDouble(1));
} catch (Exception e) {
System.out.println("GetPrice failed");
e.printStackTrace();
} finally {
ConnectionFactory.close(stmt);
ConnectionFactory.close(conn);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -