Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within EJB and other Jakarta /Java EE Technologies
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
EJB and other Jakarta /Java EE Technologies
java Ibatis if else problem
muntago Richard
Ranch Hand
Posts: 82
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
This
java
Ibatis codes inserts records into database. but i wants to use if else statement in the construct
eg
if(blablabla){ out.println("<br><font color=green size=5>Congratulations</font>"); } else{ out.println("<font color=red size=5>Problem check your database connections</font>"); }
secondly, i will like to print the records. how will i achieve that
below is the codes
import com.ibatis.common.resources.Resources; import com.ibatis.sqlmap.client.SqlMapClient; import com.ibatis.sqlmap.client.SqlMapClientBuilder; import java.sql.*; import java.io.*; import java.net.*; import java.lang.*; import javax.servlet.*; import javax.servlet.http.*; import java.sql.SQLException; import java.util.*; public class Insert2 extends HttpServlet { public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException { PrintWriter out=response.getWriter(); response.setContentType("text/html;charset=UTF-8"); String firstName = request.getParameter("firstName"); String lastName = request.getParameter("lastName"); String email = request.getParameter("email"); try { Reader reader = Resources.getResourceAsReader("sqlMapConfig.xml"); SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader); Log logging = new Log("hoke","hokes","amit@u.net"); logging.setFirstName(firstName); logging.setLastName(lastName); logging.setEmail(email); sqlMap.insert("Log.insert",Log); List<Log> ad = (List<Log>) sqlMap.queryForList("Log.getAll",null); Log insertall = new Log(); for (logging a : ad) { logging = a; System.out.print(" " + a.getFirstName()); System.out.print(" " + a.getLastName()); System.out.print(" " + a.getEmail()); System.out.println(""); } } catch(Exception e){ System.out.println(e); } } }
With a little knowledge, a
cast iron skillet
is non-stick and lasts a lifetime.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Connecting to a database through servl
error of missing values
Works with Tomcat but not weblogic
login
exception while running code
More...