Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

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!

share|improve this question

closed as not a real question by a_horse_with_no_name, dezso, Mark Storey-Smith, Marian, Jon Seigel Feb 20 '13 at 14:13

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

    
Without knowing anything about your GUI it will be hard to answer. Anyway, you can call UDFs (user-defined functions) just like any other query (eg. SELECT [* FROM] my_function()). –  dezso Feb 20 '13 at 8:45
    
You should start with the Java JDBC tutorial: docs.oracle.com/javase/tutorial/jdbc/index.html and the Java Swing tutorial: docs.oracle.com/javase/tutorial/uiswing/index.html –  a_horse_with_no_name Feb 20 '13 at 8:55
    
Thank you very much. I just edited my question based your reply. I appreciate if you take a look at my modified question and help me with that –  Amir.h Feb 20 '13 at 22:53
1  
What exactly do you mean with "I have a problem with URL"? What problem? What error? We don't have crystal balls to magically see what "the problem" is –  a_horse_with_no_name Feb 21 '13 at 7:51
    
Does mydb live on localhost? Does localhost accept connections? These would be clear if you showed the (error) meassage you'd got. –  dezso Feb 21 '13 at 8:48