Java Action programming

0
I have been trying to get my App to retrieve data from SQL for a while now, but what little I know about Java programming is from a course 4 years ago. Here is what I stuffed in the USER CODE section: class DB { public DB() {} public Connection dbConnect(String db_connect_string) { try { Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver"); Connection conn = DriverManager.getConnection(db_connect_string); System.out.println("connected"); return conn; } catch (Exception e) { e.printStackTrace(); return true; } } }; class getConnection { public void main(String[] args) { DB db = new DB(); Connection conn=db.dbConnect( "jdbc:microsoft:sqlserver://host:1433;User=user;Password=Pwd"); } } return true; How do I make it return the resultset of a query? I can't really seem to debug this as Eclipse just launches the Mendix Console, and the Mendix Console doesn't seem to care for errors in my custom code block...
asked
2 answers
1

I think you'd probably be better off checking with our neighbors, they'll probably be a lot better at helping you with SQL in java.

As to your comment about eclipse, that should work just fine, you can debug and compile stuff from within eclipse and have it run in the runtime. You do, however, have to make sure that your actions compile before starting the mendix runtime.

Btw, after rereading your question: did you paste your code between the BEGIN USER CODE and END USER CODE or did you paste ie between the EXTRA CODE tags? Methods always need to be inserted between the extra code tags. In your case, you're using a separate class, which you need to add in a different file, then reference it from the java action.

answered
0

http://lmgtfy.com/?q=call+microsoft+SQL+stored+procedure+from+java

First hit ;-)

answered