Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Statement stmt = null;
- try {
- String URL = "jdbc:mysql://localhost:3306/test";
- Connection conn = DriverManager.getConnection(URL, "myusername", "mypassw");
- stmt = conn.createStatement();
- String query = "SELECT name, salary, SalaryLevel(salary) AS level FROM mytable;";
- ResultSet res = stmt.executeQuery(query);
- while (res.next()) {
- String name = res.getString("name");
- int salary = res.getInt("salary");
- String level = res.getString("level");
- System.out.println(name + " " + salary+" "+level);
- }
- } catch (SQLException ex) {
- System.out.println(ex);
- } finally {
- if (stmt != null) {
- try {
- stmt.close();
- } catch (SQLException ex) {
- }
- }
- }
- // MySQL Stored Function Example: https://pastebin.com/bb2UPNsY
Add Comment
Please, Sign In to add comment