Plz solve the error

Please support our RSS, Web Services and SOAP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved

Join Date: Aug 2008
Posts: 16
Reputation: dhanya_piit is an unknown quantity at this point 
Solved Threads: 0
dhanya_piit dhanya_piit is offline Offline
Newbie Poster

Plz solve the error

 
-1
  #1
Oct 16th, 2009
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5.  
  6. package Programs;
  7.  
  8. import java.util.ArrayList;
  9. import javax.ws.rs.core.Context;
  10. import javax.ws.rs.core.UriInfo;
  11. import javax.ws.rs.Consumes;
  12. import javax.ws.rs.PUT;
  13. import javax.ws.rs.Path;
  14. import javax.ws.rs.GET;
  15. import javax.ws.rs.Produces;
  16. import java.util.List;
  17. import java.sql.Connection;
  18. import java.sql.DriverManager;
  19. import java.sql.ResultSet;
  20. import java.sql.SQLException;
  21. import java.sql.Statement;
  22. import java.util.logging.Level;
  23. import java.util.logging.Logger;
  24.  
  25.  
  26.  
  27. /**
  28.  * REST Web Service
  29.  *
  30.  * @author Dhanya_Kurup
  31.  */
  32.  
  33. @Path("ProgramList")
  34. public class ProgramListResource {
  35.  
  36. @Context
  37. private UriInfo context;
  38. private Logger logger = Logger.getLogger(this.getClass().getName());
  39.  
  40.  
  41. /** Creates a new instance of ProgramListResource */
  42. public ProgramListResource() {
  43. }
  44.  
  45. /**
  46.   * Retrieves representation of an instance of Programs.ProgramListResource
  47.   * @return an instance of java.lang.String
  48.   */
  49. @GET
  50. @Produces("application/xml")
  51. public ProgramDetailsList getXml() {
  52.  
  53.  
  54. //TODO return proper representation object
  55. //throw new UnsupportedOperationException();
  56. //String Strqry;
  57. Connection connection = null ;
  58. String connectionURL = "jdbc:mysql://localhost:3306/test";
  59. ProgramDetailsList Details = new ProgramDetailsList();
  60.  
  61. try
  62. {
  63.  
  64. ResultSet programResults = null;
  65. Class.forName("com.mysql.jdbc.Driver").newInstance();
  66. connection = (Connection) DriverManager.getConnection(connectionURL, "root", "bharani");
  67.  
  68. logger.log(Level.INFO, "conncetion: " + connection);
  69.  
  70. Statement stmt = connection.createStatement();
  71. stmt.setQueryTimeout(120);
  72.  
  73. programResults = stmt.executeQuery("select * from programlist");
  74.  
  75. //programResults=Strqry;
  76.  
  77. System.out.println("hii");
  78.  
  79.  
  80.  
  81.  
  82.  
  83. List<String> programName=new ArrayList<String>();
  84. //programName=null;
  85. List<String> duration=new ArrayList<String>();
  86. List<String> days=new ArrayList<String>();
  87. List<String> programType=new ArrayList<String>();
  88. List<String> description=new ArrayList<String>();
  89.  
  90. while(programResults.next())
  91. {
  92. programName.add(programResults.getString("ProgramName"));
  93. duration.add(programResults.getString("Duration"));
  94. days.add(programResults.getString("Days"));
  95. programType.add(programResults.getString("ProgramType"));
  96. description.add(programResults.getString("Description"));
  97. }
  98.  
  99.  
  100. int length=programName.size();
  101. List<ProgramDetails> program_list=new ArrayList<ProgramDetails>();
  102.  
  103. for(int k=0;k<length;k++)
  104. {
  105. ProgramDetails program = new ProgramDetails();
  106. program.ProgramName=programName.get(k);
  107. program.Duration=duration.get(k);
  108. program.Days=days.get(k);
  109. program.ProgramType=programType.get(k);
  110. program.Description=description.get(k);
  111.  
  112. program_list.add(program);
  113. }
  114.  
  115. Details.programDetailsList=program_list;
  116. stmt.close();
  117. programResults.close();
  118.  
  119.  
  120. }
  121.  
  122. catch (Exception ex)
  123. {
  124. Logger.getLogger(ProgramListResource.class.getName()).log(Level.SEVERE, null, ex);
  125. }
  126. finally
  127. {
  128. try
  129. {
  130. connection.close();
  131. }
  132. catch (SQLException ex)
  133. {
  134.  
  135. Logger.getLogger(ProgramListResource.class.getName()).log(Level.SEVERE, null, ex);
  136. }
  137. }
  138.  
  139. return Details;
  140. }
  141.  
  142. /**
  143.   * PUT method for updating or creating an instance of ProgramListResource
  144.   * @param content representation for the resource
  145.   * @return an HTTP response with content of the updated or created resource.
  146.   */
  147. @PUT
  148. @Consumes("application/xml")
  149. public void putXml(String content) {
  150. }
  151. }

this is the code that i have written....
bt its not executing
Please help...
Last edited by Ezzaral; Oct 16th, 2009 at 1:32 pm. Reason: Added [code] [/code] tags. Please use them to format any code that you post.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,189
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 483
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer
 
-1
  #2
Oct 17th, 2009
Problem description is missing, how we are supposed to know what sort of errors you getting. Plus there is no chance to second-guess what you trying to achieve...
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 16
Reputation: dhanya_piit is an unknown quantity at this point 
Solved Threads: 0
dhanya_piit dhanya_piit is offline Offline
Newbie Poster
 
0
  #3
Oct 19th, 2009
Sorry for that....
I have written the cod ein net beans....here am trying to connect to MYsql database and retrieve data from there...........
The errors that iam receiving are

com.mysql.jdbc.JDBC4Connection@c58418

Failed to initalize plugin: org.jboss.logging.Log4jLoggerPlugin@12a74c7, cause: org/apache/log4j/LogManager
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 16
Reputation: dhanya_piit is an unknown quantity at this point 
Solved Threads: 0
dhanya_piit dhanya_piit is offline Offline
Newbie Poster
 
0
  #4
Oct 20th, 2009
am also getting this error

A message body writer for Java type, class Programs.ProgramDetailsList, and MIME media type, application/xml, was not found

am unable to figure out whether am going wrong in my code or is there
some jar files missing
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,189
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 483
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer
 
-1
  #5
Oct 20th, 2009
Originally Posted by dhanya_piit View Post
Sorry for that....
I have written the cod ein net beans....here am trying to connect to MYsql database and retrieve data from there...........
The errors that iam receiving are

com.mysql.jdbc.JDBC4Connection@c58418

Failed to initalize plugin: org.jboss.logging.Log4jLoggerPlugin@12a74c7, cause: org/apache/log4j/LogManager
You did not imported Logger into your code as other packages
  1. import org.jboss.logging.Logger;
Full JBoss documentation on topic here
EDIT:
You actually tried but did it wrong
import java.util.logging.Logger;
Originally Posted by dhanya_piit View Post
am also getting this error

A message body writer for Java type, class Programs.ProgramDetailsList, and MIME media type, application/xml, was not found

am unable to figure out whether am going wrong in my code or is there
some jar files missing
Full error description as given by compiler plus relevant coding need to see what is going on. You should know this...
Last edited by peter_budo; Oct 20th, 2009 at 7:56 am. Reason: EDIT
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 16
Reputation: dhanya_piit is an unknown quantity at this point 
Solved Threads: 0
dhanya_piit dhanya_piit is offline Offline
Newbie Poster
 
0
  #6
Oct 22nd, 2009
Originally Posted by peter_budo View Post
You did not imported Logger into your code as other packages
  1. import org.jboss.logging.Logger;
Full JBoss documentation on topic here
EDIT:
You actually tried but did it wrong
import java.util.logging.Logger;
Full error description as given by compiler plus relevant coding need to see what is going on. You should know this...

Thanks a lot for spotting my error
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,189
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 483
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer
 
-1
  #7
Oct 22nd, 2009
So is this solved now or there is something else you want to ask?
If it is solved, please mark it as solved by clicking on "Mark as Solved" bellow last post.
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC