I have been given a task to create profiles for the applications. The Database that we use is Postgresql. I've defined some function that will give me those profile and I've added them to the Postgresql source code. Now I don't know how to call those functions with a GUI. I mean how connect my Graphical user interface to those funtions that I've created. For example I have a button in my GUI that is "Start creating profiles" and it's supposed to call those funcions in postgresql source code code and so on...
Any ideas of how to call those function from my GUI?
Edit:
Based on the replies, in order to use the JDBC to connect my GUI to postgreSQL, I wrote this code but I have a problem with "URL"
I know these commands in Java to connect to database(PostgreSQL):
Connection con = null;
Statement s = null;
String url = "jdbc:postgresql://localhost/mydb";
String user = "user";
String password = null;
try {
con = DriverManager.getConnection(url, user, password);
} catch (SQLException ex) {
Logger lgr = Logger.getLogger(Home.class.getName());
lgr.log(Level.SEVERE, ex.getMessage(), ex);
out.println(ex.getMessage());
}
String query = " select * from my_function()";
try {
s =con.createStatement();
r = s.executeQuery(query);
}catch (Exception e){
}finally {
try {
if (con != null)
con.close();
} catch (SQLException ex) {
Logger lgr = Logger.getLogger(HomeServlet.class.getName());
lgr.log(Level.WARNING, ex.getMessage(), ex);
}
But I'm not sure about what I have to insert in "URL" Would you please help me with that!
SELECT [* FROM] my_function()). – dezso Feb 20 at 8:45mydblive onlocalhost? Doeslocalhostaccept connections? These would be clear if you showed the (error) meassage you'd got. – dezso Feb 21 at 8:48