Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JDBC java.Sql
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Shibin Varghese
java.Sql
2 Answer(s)      6 years and 2 months ago
Posted in : JDBC



Advertisement
View Answers

August 28, 2008 at 2:48 PM


Hi friend,

To solve the problem do some changes :

1)create a "Statement" object in the while loop
Statement stmt= conn.createStatement();
2)"stmt" object closes in the while loop
stmt.close();


Connection conn;
while(true)
{
conn = DriverManager.getConnection(url+dbName,username,userPassword);
Statement stmt= conn.createStatement();
sqlstmt="SELECT * FROM tablename";
ResultSet rs=stmt.executeQuery(sqlstmt);
while(rs.next())
{
System.out.print("\n"+rs.getString(2));
}
rs.close(); // ResultSet object
stmt.close();
con.close(); //Connectuion object
}


For read more information :

http://www.roseindia.net/jdbc/

Thanks


August 28, 2008 at 3:25 PM


Hi friend,


Read for more information.

http://www.roseindia.net/servlets/


Thanks.


Related Tutorials/Questions & Answers:
java.Sql - JDBC
java.Sql  Hai Friend, In my program i have sql statement like below: while(true) { sqlstmt="SELECT * FROM tablename"; rs=stmt.executeQuery(sqlstmt); while(rs.next()) { System.out.print("\n
Introduction to java.sql package
Introduction to java.sql package       This package provides the APIs for accessing... especially relational databases. This java.sql package contains API
Advertisements
JDBC Architecture
JDBC architecture can be classified in 2 broad categories:- 1. JDBC API 2. Types of JDBC Drivers JDBC API     JDBC programming interface is found in "java.sql" and "javax.sql" packages. Given below
Prepared Statement Example
. PreparedStatement is an interface declared in the java.sql package. PreparedStatement... the JDBC to work with database java.sql provides two interfaces for executing... of java.sql package for making connection with database and to insert value
Set byte, short and long data types by using the Prepared Statement
in the PreparedStatement interface of the java.sql package. We know ... interface of java.sql package. First of all, establish the connection
Inserting Records using the Prepared Statement
the PreparedStatement interface of java.sql package.  As we all know that in database
Count Records using the Prepared Statement
interface of  java.sql package. As we know that table keeps the records in tabular
Deleting Records using the Prepared Statement
of the java.sql package. Sometimes, some records we have entered becomes useless
Using the Prepared Statement Twice
Using the Prepared Statement Twice       This JDBC tutorial helps us to use the PreparedStatement interface of java.sql package twice in a program. According to our
Set Data Types by using Prepared Statement
) in the PreparedStatement interface of java.sql package. We know that the data types of MySQL and java
Set Date by using the Prepared Statement
of java.sql package. Sometimes, if you want to insert the data into database
Set Time by using the Prepared Statement
Set Time by using the Prepared Statement       In this section you will learn about setting the time in database table by using the PreparedStatement interface of java.sql
Prepared Statement Set Big Decimal
the PreparedStatement interface of java.sql package. But here arises a question, what is big
java .sql
java .sql  where are the interfaces of java.sql like STATEMENT,CONNECTION are defined
DriverManage
DriverManage  hello, What is DriverManager ?   hii, DriverManager is a class in java.sql package. It is the basic service for managing a set of JDBC drivers
Question
java.sql package interfaces   In java.sql package majority are interfaces only, how instance will be created for these interfaces?   In java.sql package, there are several interfaces. These interfaces have been used
regarding java package - Java Beginners
regarding java package  can you provide tutorial for java.sql package please help  Hi friend, I am sending you a link. This link will help you. Please visit for more information. http://www.roseindia.net
java servlet connectivity problem with access
java servlet connectivity problem with access  Import java.sql javax.servlet //all packages entered try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("jdbc
Accessing database with JDBC via Java
in java.sql package that specifies connection with specific database like: MySQL.... DriverManager: It is a class of java.sql package that controls a set of JDBC drivers
JDBC Example with MySQL
in the database table by using the PreparedStatement interface of java.sql... by using the PreparedStatement interface of  java.sql package... the PreparedStatement interface of the java.sql package.   
JDBC CONNECTIVITY - JDBC
Friend, DriverManager-It is a class of java.sql package that controls a set
Java Mysql Connection Example
: java.sql.Connection: Connection is an interface in java.sql package that specifies... of java.sql package. It controls a set of JDBC driver. Every driver to be registered
JDBC Components
in the java.sql package for Java applications to communicate with databases. Mostly... interface in java.sql package that provides connection with the database like... with string. 3. DriverManagerThis class of java.sql package controls
Get Column Count using ResultSet in SQL
;} } Java Database Connectivity Steps1.ConnectionAn interface in java.sql... of java.sql package that controls the JDBC drivers. Each driver has to be register...*; The star '*' indicates that all of the classes in the java.sql and java.io
Connecting to a MySQL Database in Java
Description of code: Connection: This is an interface in  java.sql package...: It is a class of java.sql package that controls a set of JDBC drivers. Each driver has
Insert current date into MYSQL database
of java.sql package and pass the current date to it using Java.util.Date class
Retrieve date from MYSQL database
class and Date class of java.sql package to fetch the dates from table
Jdbc Mysql Connection Url
have a code that includes a java.sql package, this package enables you a network
Database Connectivity Example In Java
the queries. These interfaces/classes are available into the java.sql and javax.sql package. (javax.sql package is extension package of basic java.sql package
JDBC Insert Preparedstatement
JDBC Insert Preparedstatement       The java.sql package contain a prepared...;import a package java.sql - this provides you a network interface that help
Using WHERE Clause in JDBC
in java.sql package that provides connection with the database like- MySQL... is a class of java.sql package that controls the JDBC drivers. Each driver has
Advertisements
 

 

 

DMCA.com