[Users] Petals Starting Guide - day 4 (Jsr-181): Java to WSDL -> NOT WORKING

petaleRose [via Petals Forums] ml-node+s974793n4022331h35 at n3.nabble.com
Wed May 30 14:22:08 CEST 2012



Dear Sir, i have written few methods retrieving and writing some data in
mysql database and i got one error: "1 error occured during the generation
process. Check the log for more details". 

But There is NOTHING like an error in the Log and generating the wsdl file
out of the java class is not working at all.

Here is my program with the methods...

Id_booker.java
******************

// variable for the connection
                private  Connection conn = null;
                private  Statement  statement = null;
                private  ResultSet result = null;
                private  int id;
                private  String msg;

                /**
                 *
                 */
       
            @WebMethod( operationName="getConnection" )
            @WebResult( name="returngetConnection" )
            public  Connection getConnection() throws Exception {
                 
                        try{
                                String driver = "com.mysql.jdbc.Driver";
                            String url =
"jdbc:mysql://localhost:3306/id_manager";
                            String username = "root";
                            String password = "petals";
                            Class.forName(driver);
                            Connection conn =
DriverManager.getConnection(url, username, password);    
                               
                        }catch(Exception e) // has to be checked properly!
                        {
                                e.printStackTrace();
                                System.out.println("Http 500: Server error
due to a database access error or to the fact that this method is called on
a closed connection");
                                //throw e;
                        }
                       
                   
                    return conn;
            }
           
           
            @WebMethod( operationName="ChekIdDatabase" )
            @WebResult( name="returnChekIdDatabase" )
            public boolean ChekIdDatabase(int id) throws Exception
                {
                        boolean res = false;
                       
                        try
                        {
                                String query = "";
                                conn = getConnection();
                                statement = conn.createStatement();
                                query = "SELECT * FROM `msg_storage` where
id = "+id;
                                result = statement.executeQuery(query);
                                result.last(); //pointing the cursor on the
last row only then the number of rows/match can be read!
                               
                                if(result.getRow()!=0){
                                        res = true;
                                }
                               
                        } catch (Exception e)
                        {
                                 e.printStackTrace();
                                 throw e;
                        }
                        finally
                        {
                                close();
                        }
                       
                        return res;
                }
           
           
            /**
                 * stores the id in the DB
                 *
                 * @param id is the id to be stored
                 * @param msg is the matching message to be stored
                 * @return in String "http 200" if successful or "http 500"
if an error
                 * occured while writing in the DB
                 */
            @WebMethod( operationName="WriteIdDatabase" )
            @WebResult( name="returnWriteIdDatabase" )
                public String WriteIdDatabase(int id, String msg) throws
Exception
                {
                        String res = "http 200 The id '"+id+"' has been
stored sucessfully!"; // successful
                        try
                        {
                                if(ChekIdDatabase(id)== false)
                                {
                                        System.out.println("\n Id has NEVER
been booked in the DB !");
                                        String query = "";
                                        conn = getConnection();
                                        statement = conn.createStatement();
                                        query = "INSERT INTO
`id_manager`.`msg_storage` (`id`, `msg`) VALUES ('"+id+"',
'message-"+id+"');";
                                        int var =
statement.executeUpdate(query);
                                        System.out.println("\n"+var +" row
affected");
                                }else
                                {
                                        res = "The id '"+id+"' is already
stored in the DB. It can not be done twice! ";
                                }
                               
                        } catch (Exception e) {
                                 e.printStackTrace();
                               
                                 throw e;
                        } finally {
                                close();
                        }
                        return res;
                }
               
               
           
            /**
                 * close all the opened connections to the DB
                 */
            @WebMethod( operationName="close" )
            @Oneway
                public void close()
                {
                        try {
                                if (result != null) {
                                        result.close();
                                }

                                if (statement != null) {
                                        statement.close();
                                }

                                if (conn != null) {
                                        conn.close();
                                }
                        } catch (Exception e) {

                        }
                       
                }

Can somebody please help me find out why generating a wsdl file out of this
java class is not working? Have i forgotten some driver for mysql... or
something like this... because, i got NO ERROR inserting "import
java.sql.*".

Please i would really like to uderstand.

Thank you. 

_______________________________________________
If you reply to this email, your message will be added to the discussion below:
http://forum.petalslink.com/Petals-Starting-Guide-day-4-Jsr-181-tp2686713p4022331.html
To start a new topic under Users (get help, provide help), email ml-node+s974793n2681628h42 at n3.nabble.com
To unsubscribe from Users (get help, provide help), visit http://forum.petalslink.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=2681628&code=dXNlcnNAZm9ydW0ucGV0YWxzbGluay5vcmd8MjY4MTYyOHwtOTE3MDU0NjU4
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://forum-list.petalslink.org/pipermail/users/attachments/20120530/7fe15fa9/attachment.htm>


More information about the Users mailing list