Shridhu Chandel
problem in jsp programming
1 Answer(s)      6 years and 4 months ago
Posted in : JSP-Servlet
Advertisement
View Answers

March 21, 2009 at 2:38 AM


Hi friend,


Code to help in solving the problem :

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">;

<%@ page import="java.sql.*,java.text.*,java.util.*" %>
<%@ page import="java.io.*" %>

<html>
<head>
<title>Connection with mysql database</title>
</head>
<body>
<h1>Connection status </h1>
<table>
<tr><td>Item Name</td><td>Company</td><td>Address</td></tr>
<%
try {

Date date = new Date();

// Some examples
Format formatter = new SimpleDateFormat("yyyy-MM-dd");
String currentdate = formatter.format(date);

/* Create string of connection url within specified format with machine name,
port number and database name. Here machine name id localhost and
database name is usermaster. */
String connectionURL = "jdbc:mysql://localhost:3306/usermaster";;

// declare a connection by using Connection interface
Connection connection = null;

// Load JBBC driver "com.mysql.jdbc.Driver"
Class.forName("com.mysql.jdbc.Driver").newInstance();

/* Create a connection by using getConnection() method that takes parameters of
string type connection url, user name and password to connect to database. */
connection = DriverManager.getConnection(connectionURL, "root", "root");
Statement stmt = connection.createStatement();

String query = "select * from table where itemdate='"+currentdate+"'";
ResultSet rs = stmt.executeQuery(query);
while(rs.next())
{
%>
<tr><td><%=rs.getString("item_name")%></td><td><%=rs.getString("company")%></td><td><%=rs.getString("address")%></td></tr>
<%
}

}
catch(Exception ex){
%>
</font>
<font size="+3" color="red"></b>
<%
out.println("Unable to connect to database.");
}
%>
</table>
</font>
</body>
</html>

Thanks









Related Tutorials/Questions & Answers:
problem in programming - JSP-Servlet
problem in programming  Hi! I am new with jsp. I am facing a problem in programming to calculate the time interval between login time and logout time of user
problem in jsp programming - JSP-Servlet
problem in jsp programming  Write a JSP program which displays a webpage containing arrival of new items within a particular month in the different... in solving the problem : Connection with mysql database
Advertisements
programming problem
programming problem   Kingdom of Maplewood is a beautiful country comprising of a lot of small islands of different areas. All the islands are in a straight row. King Rosewood is getting old and has decided to divide the islands
java programming problem - JDBC
java programming problem  Hi, Request you to provide the source code in Java for the following programming problem : upload .csv file data into oracle database. please send the solution to raichallp@yahoo.in
java programming problem - JDBC
java programming problem  Hi, Request you to provide a solution ( analysis & design & unit test plan & code & test criteria ) to the following problem to the following mail id : Problem : upload excel file data into oracle
Programming problem - Java Beginners
Programming problem  Good afternoon Ma'am/Sir, Can you help me... it difficult to learn java programming? Based on my survey it seems that java programming is the hardest part of their studies.. I also want to know
Programming with JSP
Programming with JSP  Write a program using jsp that accepts a course code as input and displays the course title the program to which it belongs
programming problem - Java Beginners
programming problem  i am using FileDialog to select an image and displaying it on a canvas using getDirectory() and getFile(). now i want to use the path obtained from getDirectory() and getFile()to obtain same selected image
java programming problem - Java Beginners
java programming problem   Given a deck of ncards unique cards.Cut the deck iCut cards from the top portion of the deck followed by the bottom card... etc. Alternating the remaining cards go on top. The problem is to find
Programming with JSP
Programming with JSP  Who will post me the answer
java programming problem - Java Beginners
java programming problem   num=(a/b)*(c/d) In the problem, 'num' is given . "0<2" we have to find out the values of a,b,c,d upto five places of decimal. there can be many combinations of a,b,c,d . the solution space
jsp programming
convert a pdf file int svg file using pdftron and dishplay in jsp at run time JSP  I am also in trouble is that I want to convert a pdf file int svg file using pdftron and dishplay in jsp at run time. plz guide me n thanks
jsp programming
converting a pdf file to png format using pdftron JSP programming  Hello, I am trouble in converting a pdf file to png format using pdftron. plz guide me, n thanks in advance
Java programming problem - Java Beginners
Java programming problem  could anyone help me to solve this problem... Implement a superclass Person. Make two classes, Student and Instructor that inherit from Person. A Person has name, year of birth and day. Student has
Programming - JSP-Servlet
Programming jsp servlet   Couple of examples that can help to start programming jsp servlet
Problem in jsp.
Problem in jsp.  hello friends, I have a problem in jsp.I want to insert data, which is given by user through a html page into a table.And the table..." action="http://localhost:8080/examples/jsp/insertdata.jsp"> <table> <
Problem in jsp.
Problem in jsp.  hello friends, I have a problem in jsp.I want to insert data, which is given by user through a html page into a table.And the table..." action="http://localhost:8080/examples/jsp/insertdata.jsp"> <table> <
Problem in jsp.
Problem in jsp.  hello friends, I have a problem in jsp.I want to insert data, which is given by user through a html page into a table.And the table..." action="http://localhost:8080/examples/jsp/insertdata.jsp"> <table> <
Jsp problem
Jsp problem  Hello friends.I want to share my jsp problem.I want to show all of my database(mysql) tables except two(user,manufacturer) in a jsp page.plssss help me
java programming problem - Java Beginners
java programming problem  Hello..could you please tell me how can I count the occurrence of EACH alphabet in a string..? Thanks  Hi Ruby I am sending some link where you can find solution of your prblem
java programming problem - Java Beginners
java programming problem  we are given a number ,num. ( 0<2 ) we have to represent the number(num) in the form of a,b,c,d such that: num=(a/b)*(c/d) for eg. let num=2, then a=1.5 b=0.75 c=0.4 d=0.4
Java Programming Problem - Java Beginners
Java Programming Problem  Q. How write a program that asks the user's name, and then greets the user by name. Before outputting the user's name, convert it to upper case letters? For example, if the user's name is Fred
jsp problem
jsp problem  problem:::::::: On JSP form ,when i insert data in text field........at that time action is perform and data is retriev from data base and get assign to other field on that form........ when data is assign to other
jsp problem
jsp problem  Hello Friends, I want to show one page for 5 seconds and after that i want to redirect the page to another URL
jsp problem
jsp problem  Hi every one plz give me answer for below question ASAP I created one JSP(used pre defined javascript in jsp to get rtf format in browser) which creats RTF Format in browser to enter data. MY question is after i
jsp programming - JSP-Servlet
jsp programming  How to retrieve the invoices from the tally to jsp
Programming in JDBC and JSP - JSP-Servlet
Programming in JDBC and JSP  Write a program using JDBC and JSP to display the names and addresses of all those MCA students at your study centre... Semester.   Hi friend, Code to help in solving the problem
JSP Problem - JSP-Servlet
JSP Problem  Hi, I have problem,this is my senario I have one jsp,this jsp having the 3 fields.let me take 3fields userName,emailAddress... for more information, http://www.roseindia.net/jsp Thanks
jsp problem - JSP-Servlet
jsp problem  here is a code for Retrieving image from mysql database through jsp. but i cann't set size of image when it was display so what should... working but my problem is size of image. so can u just help?? code
jsp problem - JSP-Servlet
jsp problem  here is a code for Retrieving image from mysql database through jsp. but i cann't set size of image when it was display so what should... working but my problem is size of image. so can u just help?? code
jsp problem - JSP-Servlet
jsp problem  hi, i am working on a project of developing a shopping cart for online book store.can it be done using jsp?if yes, can u please help me doing so?  Hi Friend, Please visit the following link: http