Results 1 to 3 of 3
  1. #1
    Jack_Tauson_Sr is offline Senior Member
    Join Date
    Nov 2011
    Posts
    164
    Rep Power
    7

    Default Printing on Console

    For example in my webservice, if I have to display something in the console, I have seen people printing it like the following using logger class :


    Java Code:
     210: 	@RequestMapping(value="/getemployeelist", method=RequestMethod.GET)
      211:     public String getemployeelist
      212      (
      213      	@RequestParam(value="empid", defaultValue="") String empid_,
      ...
      219  		
      220  		logger.info("-----------------------------------------------------------------------------------------------------------");
      221: 		logger.info("getemployeelist parameters: employee ID  = " + empid_ + ");
    Now, suppose, if I need to print the SQL statements generated using String builder, how can I see the SQL statement in the console?

    For example, for the following :

    Java Code:
     try {
             
    		 ds = jdbcTemplate.getDataSource();
    			conn = ds.getConnection();
      
      
             // Generate the query
    			StringBuilder sql = new StringBuilder();
    			sql.append("select ");
    			sql.append("emp_id , ");
    			sql.append("emplogin , ");
    			sql.append("start_date ");
                sql.append("from emptable ");
      
      
      
      
       }
    Is it possible to use something like this? :

    logger.info("getemployeelist SQL: Full SQL = " + sql + ");


    I tried but it said "logger" can't be resolved and generated an error.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    25

    Default Re: Printing on Console

    Have you defined a logger for that class?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    Jack_Tauson_Sr is offline Senior Member
    Join Date
    Nov 2011
    Posts
    164
    Rep Power
    7

    Default Re: Printing on Console

    Quote Originally Posted by Tolls View Post
    Have you defined a logger for that class?

    I haven't, probably that might be the issue. I have one more question which I am posting in a separate thread where I am not seeing the logs.

Similar Threads

  1. Replies: 0
    Last Post: 12-26-2011, 03:52 PM
  2. Replies: 9
    Last Post: 08-19-2011, 12:59 AM
  3. Creating a deck of cards and printing in console
    By Danieldcc in forum New To Java
    Replies: 7
    Last Post: 10-12-2010, 07:37 AM
  4. The tomcat server is not printing the exception to the console
    By linux0kernel in forum JavaServer Pages (JSP) and JSTL
    Replies: 3
    Last Post: 08-12-2010, 07:30 AM
  5. Need help with printing console output to JTextArea
    By ShinTec in forum AWT / Swing
    Replies: 4
    Last Post: 06-04-2010, 10:10 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •