java.Sql

java.Sql

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 ADS_TO_REPLACE_1 JDBC API     JDBC programming interface is found in "java.sql" and "javax.sql"
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... and interfaces of java.sql package for making connection with database
Set byte, short and long data types by using the Prepared Statement
in the PreparedStatement interface of the java.sql package. We know ... the PreparedStatement interface of java.sql package. First of all, establish
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,ADS_TO_REPLACE_1 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
table by using the PreparedStatement interface of java.sql package.  ... the PreparedStatement interface of  java.sql package.   ... interface of the java.sql package.    Using
JDBC CONNECTIVITY - JDBC
Friend, DriverManager-It is a class of java.sql package that controls a set
Java Mysql Connection Example
in java.sql package that specifies the connection with specific database...:- Driver Manager is a class of java.sql package. It controls a set of JDBC driver
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
: This is an interface in  java.sql package that specifies connection with specific database... string. DriverManager: It is a class of java.sql package that controls a set
Jdbc Mysql Connection Url
have a code that includes a java.sql package, this package enables you a network
Insert current date into MYSQL database
of Date class of java.sql package and pass the current date to it using
Retrieve date from MYSQL database
used the TimeStamp class and Date class of java.sql package to fetch the dates
Connection using Jdbc-odbc bridge Driver
_TO_REPLACE_2 Description of code import java.sql -- Since 'java.sql'
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
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
Database Connectivity Example In Java
and to write the queries. These interfaces/classes are available into the java.sql... java.sql package) ExampleADS_TO_REPLACE_2 Here an example is being given example
Introduction to the JDBC
. Java.sql that ships with JDK contains various classes for using
Connecting to the Database Using JDBC and Pure Java driver
are defined in java.sql package, so it is necessary to import
Package categories in Java
components.  java.sql It provides
Using Select Statements in JDBC
the data. Description of Code1.First in the program we import the java.sql
JDBC Connectivity Code In Java
required to connect url and database, we import a package java.sql,enables you
JDBC Get Row Count
;Import a package java.sql*,enables you to provide a network interface
JDBC Exception
is to import a package name java.sql include a definition for all the classes
JDBC: MetaData Example
JDBC: MetaData Example In this section we are discussing how to get information of MetaData using JDBC API. MetaData  : DatabaseMetaData interface is mentioned in java.sql package. It is implemented by the Driver vendors which
JDBCTutorials
that address a number of areas of missing functionality. Both the java.sql... features in the java.sql package as well as the new Standard Extension package... database computing. New features in the java.sql package include support
First Step towards JDBC!
that enables the Java application to communicate with databases. Java.sql
ResultSetMetaData - JDBC
(); } } } DatabaseMetaData: This is an interface of java.sql package
Product Components of JDBC
interface is divided into two packages i-) java.sql ii-) javax.sql. 
Retrieving Tables from a Database
: DatabaseMetaData: This is an interface of java.sql package that implemented
Prepared Statement Set Object
; PreparedStatement: This is an interface of java.sql package which extends Statement
Set Timestamp by using the Prepared Statement
the PreparedStatement interface of java.sql package. If you want to insert the Timestamp
Getting Column Names from a database table in Java
of java.sql package that can be used for getting information about types
GET DATE in JDBC
in the program we import the java.sql and java.io packages then define the GetDate
JDBC Execute Query
below -Java.sql.* - This Java.sql* package is imported that contain the definition

Ads