how to chech result set is null or not

how to chech result set is null or not

View Answers

November 28, 2008 at 3:22 AM

Hi friend,

Code to help in solving the problem :

import java.sql.*;
public class CheckResultSet {
public static void main(String[] args) throws Exception {
String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://localhost:3306/";;
String username = "root";
String password = "root";
String dbName= "dbName";
Class.forName(driver);
Connection conn = DriverManager.getConnection(url+dbName, username, password);
System.out.println("Connected");
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery("SELECT * FROM table");
if(rs!=null)
{
System.out.println("ResultSet is not null");
}
st.close();
conn.close();
}
}

For more information on JDBC visit to :

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

Thanks









Related Tutorials/Questions & Answers:
how to chech result set is null or not - Java Beginners
how to chech result set is null or not  Hi, really very thanks for fast reply.I want to know how to check whether the result set is null...("SELECT * FROM table"); if(rs!=null) { System.out.println
How to add a columns with a button set to a Jtable built with database result set
How to add a columns with a button set to a Jtable built with database result set  hi, i have to build a gui to display account numbers and account... that button column to the table which is built with database result set. i would thank
Advertisements
How can we find the number of rows in a result set using PHP?
How can we find the number of rows in a result set using PHP?   How can we find the number of rows in a result set using PHP
how to store the REsult Set values in array and loop through it in java?
how to store the REsult Set values in array and loop through it in java?  I have two tables Slink and Locate Slink has column name Slinkid ,locate.... how can i do
how to store the REsult Set values in array and loop through it in java?
how to store the REsult Set values in array and loop through it in java?  I have two tables Slink and Locate Slink has column name Slinkid ,locate.... how can i do
Result=Set - Java Beginners
Result=Set  Hi Friend, Can u tell how to get the count of records... result set, first move the pointer from first record to last record and get... visible='v';"; rs=stmt.executeQuery(sqlstmt); How can i get the number of record
Sort Result set
Sort Result set   I build a connect for my page with the database... name is a hyperlink. also how to delete a row from the table? if I have... but please I need the easer one. for the both I don't know how to connect
Hibernate Narrowing Criteria Result Set
Hibernate Narrowing Criteria Result Set In this tutorial you will learn how to narrow the Criteria result set. In Hibernate result set can be narrowed... will demonstrates how can you narrow the result set. For creating this example
How many ways we can retrieve the date in result set of mysql using php?
How many ways we can retrieve the date in result set of mysql using php?  How many ways we can retrieve the date in result set of mysql using php
How many ways we can retrieve the date in result set of mysql using php?
How many ways we can retrieve the date in result set of mysql using php?  How many ways we can retrieve the date in result set of mysql using php
How many ways we can retrieve the date in result set of mysql using php?
How many ways we can retrieve the date in result set of mysql using php?  How many ways we can retrieve the date in result set of mysql using php
How many ways we can retrieve the date in result set of mysql using php?
How many ways we can retrieve the date in result set of mysql using php?  How many ways we can retrieve the date in result set of mysql using php
How many ways we can retrieve the date in result set of mysql using php?
How many ways we can retrieve the date in result set of mysql using php?  How many ways we can retrieve the date in result set of mysql using php
How many ways we can retrieve the date in result set of mysql using php?
How many ways we can retrieve the date in result set of mysql using php?  How many ways we can retrieve the date in result set of mysql using php
How many ways we can retrieve the date in result set of mysql using php?
How many ways we can retrieve the date in result set of mysql using php?  How many ways we can retrieve the date in result set of mysql using php
Result Set one to many mapping
Result Set one to many mapping  Suppose there are 5 tables... Suppose result contains single entry of One record for A, Two records for B , three records for C , Four records for D and two records for E. Then how should
Spring Null value, Set null value in Springs configuration file
Spring Null value, Set null value in Springs configuration file In this example you will see how to set null value in the Spring configuration file... this application it will display output as shown below:     null
java.sql.SQLExceptioan: Before start of result set - JDBC
java.sql.SQLExceptioan: Before start of result set   java.sql.SQLException: Before start of result set?what do i do?   Hi Friend... accessing the result like the following: while(resultSet.next()){ String st
Null value when i set interface object in form controller - Spring
Null value when i set interface object in form controller   Hi all, i am very new about spring and hibernate. i got null value when i set... got NULL pointer exception ... please guide me if any one know ...it is very
pyspark dataframe drop null - how to drop row with null values
pyspark dataframe drop null - how to drop row with null values  Hi... all the rows having address is NULL. how to do this? thanks   Hi, you... address is not NULL") Thanks
How to set cookies?
How to set cookies?  How to set cookies
How to set the cursor to wait?
How to set the cursor to wait?  How to set the cursor to wait
how to set class path
how to set class path  how to set class path in java
how to set image - EJB
how to set image   public ActionForward execute(ActionMapping mapping... in this pdf, how can i set pls help me sir, my image in E:/rose.jpg,how can... contains # report after result filling * process */ JasperPrint
how to set the values in jsp
how to set the values in jsp  how to set the values text boxs in jsp frm dbase via servlet
how set data in a dialog
how set data in a dialog  Button button = (Button) findViewById(R.id.button1); button.setOnClickListener(new View.OnClickListener...(instruction,BufferType.NORMAL); builder.setPositiveButton("pay", null
how to set background image
how to set background image  how to set image in background in that image i want over lay text how it possible in jsp? using flash image how it is overlayed in jsp page? thanks
How to set NSZombieEnabled iPhone
How to set NSZombieEnabled iPhone  Hi, In my application I have to find and fix the object release issue. How to set NSZombieEnabled iPhone to find the bugs? Thanks   Hi, Please see the thread NSZombieEnabled iPhone
UINavigationController how to set title
UINavigationController how to set title  I want to set the tile of the UINavigationController when a view is displayed once new view is pushed. Thanks   Hi, You should use the following code
how can i display a editable result of form?
how can i display a editable result of form?  how can i display a editable result of form? i know how to display form result but the result... show the result but i can not modify the result. how can i display modifyable
How to set target to videos??
How to set target to videos??  Hi, i am developing project in HTML 5 with videos so, i am dispalaing videos in two table coloumn,if the video in one coloumn is clicked,it should be played in another coloumn. plzz suggest any idea
how to set value of dropdown list
how to set value of dropdown list  Hello Sir, I'd solved the earlier... the value from a link to a dropdown list. I want to set the dropdown list selected..._TO_REPLACE_1 if(hr!=null && min1!=null && am1!=null
how to set value of dropdown list
how to set value of dropdown list  Hello Sir, I'd solved the earlier... the value from a link to a dropdown list. I want to set the dropdown list selected... am1 = request.getParameter("am"); String str=""; if(hr!=null &
how to set the value of textfield constant
how to set the value of textfield constant  how to set the value of textfield constant
how to set folder size in php
how to set folder size in php  hi , i know how to create folder but i dont know how to set size for folder did u know means tell me. thankyour
how to set time in jsp page
how to set time in jsp page   I need code for set the time in jsp code .iam using struts frame work back end oracle 10g ide is eclipse 6.0
how to sort the result of this 2 class program in java.....????
how to sort the result of this 2 class program in java.....????  package setget1_method; import java.util.Scanner; public class Main { { { Scanner input = new Scanner(System.in); LBook[] book = new LBook[5]; String
how to set size of button,textfield.
how to set size of button,textfield.  how we set size of button... large how to set as a preferd size in the panel or frame .when we click maximize button not effect on text or button to their of size the set on the prefered
How to set Marathi font to Label??
How to set Marathi font to Label??  Hello, I am doing one project in java-Swing Farm Management i want to set Marathi label in that so how i can? plzzzz help me its urgent
PHP SQL Null
PHP SQL Null       This example describes about handling NULL values in sql query in php. The result produced by SQL SELECT command may contain NULL or non-Null values. So
How to set placeholder in uitextfield programmatically?
How to set placeholder in uitextfield programmatically?  Can any one tell me about the example code for setting the placeholder in a UITextField programatically? Thanks   HI, Its easy. Use the following code
Hibernate Criteria Setfirst Result
Hibernate Criteria SetFirstResult Result The setFirstResult of hibernate criteria API is used for setting no of records to be fetched from the table criteria.setFirstResult(1); An example of set first is given below
how to set a image in frame? - Swing AWT
how to set a image in frame?  how to set a image in frame using swing
how to set fetch size for jdbc odbc driver
how to set fetch size for jdbc odbc driver  What is the default fetch size for the JDBC ODBC driver and how can i fetch a set of results for JDBC... that it may handle out of memory issues. When you set fetch size 100 , the number
How to do Null validation for a boolean variable - Java Beginners
How to do Null validation for a boolean variable  How to do Null validation for a boolean variable in JAVA?  Hi friend, For solving the problem visit to : http://www.roseindia.net/java/master-java/variables
how to export the query result in SQL Server to .csv file?
how to export the query result in SQL Server to .csv file?  how to write table data into CSV file using SQL SERVER 2008
HOW TO DISPLAY 2 SET OF CONTROLS
HOW TO DISPLAY 2 SET OF CONTROLS  i can be display one row by selecting value from drop down box BUT ALSO i need to display 2 rows by selecting value from drop down box of textbox's and radio button,drop down box using this code
How to set CLASSPATH in Java?
What is CLASPATH in Java and how to set it?   ... of PATH and CLASSPATH ? How it is set in environment variable?. ANS... on okADS_TO_REPLACE_16 How to set System Classpath : Java class path
How to set heap memory in cassandra on docker
How to set heap memory in cassandra on docker  I am trying to run cassandra on docker and its throwing error asking to set the heap memory..._SIZE=2048M How to set the heap memory in cassandra on docker? Thanks  
how can i set an object in focus
how can i set an object in focus  There is a Canvas object in my game and this object is not set in focus, because of this my snake is not moving...(); if(snakeTile == null || snakeTile.equals(TileType.SNAKE)) { gameOver = true

Ads