Home Answers Viewqa JDBC Data base related question

 
 


raja
Data base related question
1 Answer(s)      2 years and 6 months ago
Posted in : JDBC

sir my table has only one element(that is pno),i am using ms-access as backend. i put only one element i want to retrieve that element .how can i retrieve that element,using jdbc technology.

please csee my code

import java.sql.*;

class raja {

int regd1; public int k() {

try {

Connection con2=null; Statement stmt2=null; ResultSet rs2=null; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con2=DriverManager.getConnection("jdbc:odbc:oldp");

stmt2=con2.createStatement(); String st2="select * from pname order by pno"; System.out.println(""+st2.toString());

rs2=stmt2.executeQuery(st2); System.out.println("hi"); while(rs2.next()) regd1=rs2.getInt(1); else System.out.println("hi");

stmt2.close(); con2.close(); } catch(Exception e) { e.printStackTrace(); }

return regd1; } public static void main(String args[]) { raja p=new raja(); p.k(); } } //could you please tell me the way.

View Answers

December 6, 2010 at 3:51 PM


Hi Friend,

You can try the following code:

import java.sql.*;
class RetrieveData{
    public static void main(String[] args){
        try{
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
           Connection con = DriverManager.getConnection("jdbc:odbc:student");
           Statement st=con.createStatement();
           ResultSet rs=st.executeQuery("select * from data");
           while(rs.next()){
               System.out.println(rs.getInt("id"));
           }
        }
        catch(Exception e){
        }
    }
}

Thanks









Related Pages:
Data base related question
Data base related question  sir my table has only one element(that is pno),i am using ms-access as backend. i put only one element i want to retrieve that element .how can i retrieve that element,using jdbc technology. please
project related question
project related question  1- how to insert a date through hibernate 2- how to insert exact time ,date separetly in the data base for current time date
data base question - Java Interview Questions
data base question  first we create a table with out create primary kay,after that i want to create same record with primary key,but no duplicate record,no deletion and after creation.  Hi, Query to create
Java and jvm related question
Java and jvm related question  What is difference between java data types and jvm data types
Restlet Frame work Related question
Restlet Frame work Related question  How to send data from client to server using Restlet framework. The main problem is i am not able to get data at server side. Can anyone post a complete program how to achieve
data base
data base  how to connect coding in data base ?   The given code connects JSP page to database. You need to import the mysql connection jar file to jdk as well as to the lib of tomcat. Moreover you need to set classpath
DATA BASE
DATA BASE  Create a program to establish a connection to the PCTBC... the data using a J Table.   Here is a code that connects to MySql... main(String[] args) { Vector columnNames = new Vector(); Vector data = new Vector
Other Base Packages
Other Base Packages I/O For handling i/o of an application in java , java.io... classes etc. Security This package provide us APIs for enhancing security related... for processing of XML data and documents. Java Native Interface (JNI) JNI stands for Java
question
question  Good Afternoon Sir, give me the source code to submit attendance to data base using System IP Address with system date and time.using JPanel+mysql+java
question
question  i need a jsp/html program which includes drop down menu for leave types and a button for apply leave.and need another jsp to validate types of leave and then insert in to data base using mysql
question
question  how to put every data base connections (selection,insertion ,updation and so on) in one jsp page and how to import that in other pages of one project
question
question  good afternoon sir, i need a jsp/html program which includes drop down menu for leave types and a button for apply leave.and need another jsp to insert types of leave which is selected by the user ,in to data base
question
question  good afternoon sir, i have a project in jsp which contains attendance marking.i could mark present successfully but i want to list absentees.i need a jsp code to insert absent,half day leave in to data base while user
Data base Connectivity
Data base Connectivity  How to configure JDBC connection for Oracle data base.In configuring it is asking select Data server name and TNS.I typed Oracle for Data Server Name and IN TNS what to type? I pulled the list for TNS
iphone property list related
iphone property list related  question related to iphone application...... how to retrieve data from plist and again check the condition if data is found in plist then go to next view and print those value in table
Question related to Hibernate
Question related to Hibernate  Why do we use Set in child class in 1:many hibernate ,why can't we use Directly HashSet
JSP data base validation
JSP data base validation  please explain how to validate form input string with database n also how its notify that entered data exists already... bol = ps.execute(); out.println("Data Added Successfully
Data base - JDBC
Data base  I want to do this Inserting a record with Object type column using PreparedStatement but wht should b the column datatype this is te..."); con.close(); }//main }//class For this should i create a user defined data type
Struts related Question
Struts related Question  Hi All, I have a one question on validation framework for client side validation please help me on that. suppose i don't want to put required=true in our JSP then what will happen. what error will come
java question related to objects
java question related to objects  what is the output of the following code? public class objComp { Public static void main(String args[]) { Int result = 0; objComp oc= new objComp(); object o = oc; if( o==oc) result =1; if(o
java related question
java related question  How can we make a program in which we make mcqs question file and then make its corresponding answer sheet....like if we make 15 mcqs then java should generate it answer sheet of 15 mcqs with a,b,c d
Java Related Question
Java Related Question  hi, Why java doesn't has primitive type as an object,whats an eligibility to have a primitive type as an object by the languages
string related question
string related question  *q.1>how i dispaly the reference of string variableS ? eg:-String s1="my name"; Sring s2="your name"; here what is address of variable s1 and s2
JDBC related Problem - JDBC
this when i executed this program and checked into the data base .... other...JDBC related Problem  Hey plz check out the following code .... import java.sql.*; class DatabaseStore { public static void main(String
Web Related - JSP-Servlet
question is how can i refresh my webpage automatically after time slide. plz give... Add data into database Name Last Name
java fundamental question related to string
java fundamental question related to string  public class Myclass { Public static void main(String args[]) { String s=â??helloâ??; StringBuffer sb=new StringBuffer(s); Sb.reverse(); If(s==sb) system.out.println(â??aâ
please send me the banking data base in swings
please send me the banking data base in swings  sir, please send me how to create the banking data base program in swings
for store data in data base - JSP-Servlet
for store data in data base  i want to a job site, in this site user can registered by a form.. in this form there are his information... i use..... and on 3rd form i use submit button... data of form 1 and 2 can also be store
related to database
related to database  how to override existing values in table? when user enters his updated data through query
get data in pop up window droplists and on selecting data in the same show a grid table with related datas
down have country names which need to be fetched from data base(let it be country...get data in pop up window droplists and on selecting data in the same show a grid table with related datas  Hi, Please help me urgently.... I need
Retrive the data from the table in data base using jdbc
Retrive the data from the table in data base using jdbc  Retrive the data from the table in data base using jdbc   JDBC Tutorials
insert excel value in to oracle data base
insert excel value in to oracle data base  Hi All I am using...); System.out.println("Data is inserted... the data from the excel file using JDBC. For this you need to create dsn
Lang and Util Base Libraries
Lang and Util Base Libraries The Base libraries provides us the fundamental features and functionality of the Java platform. Lang and Util Packages Lang... and fetch/ retrieve preferences of system and user and also data
java code for threading example for connecting data base
java code for threading example for connecting data base  Write a program that has two threads First thread queries the database and fetches all the employee records from the emp table. Stores the employee objects
my question is related to my project viz
my question is related to my project viz   Sir, my project is based on MR tracking system developed using struts framework, it has been developed in Net Beans the whole project is working except a jsp page named dayplan.jsp
when refreshing the page the data is stored in data base again
when refreshing the page the data is stored in data base again  Hi, In my application, I am adding form data in database on click of submit button.But the problem is, when user refreshes the page, the data added one more time
Retrieving data from data base using jsp combo box
Retrieving data from data base using jsp combo box  Hi guys please help me , i have on GUI page int that Server type(like apache,jboss,weblogic) one combo box is there and another filed is version of the server(like 1.0,2.0) like
retrive data from data base and print it in every page until logout
retrive data from data base and print it in every page until logout  suppose that a user login your website through user name & password. now after completion of login he goto home page.inside home page i want to print
JAVA QUESTION
ENTER THE DATA THAT WILL BE SUCCESSFULLY SAVED INTO DATA BASE WITH OUT WRITING... THE DYNAVALIDATORACTIONFORM THIS WILL BE SUCCESFULL. NOW MY REQUIERMENT IS TO GET DATA FROM DATABASE AND SEND TO USER IN FORM LIKE WITH OUT PRINTING DATA IT WILL RETURN LIKE A DATA
data (image ,audio) inserting to data base (oracle 10g) and retriving the same data from jsp
data (image ,audio) inserting to data base (oracle 10g) and retriving the same data from jsp   data (image ,audio) inserting to data base (oracle 10g) and retriving the same data from jsp with script of data base plz help me
question
question  how to insert data in to table using bean + jsp
question
question  sir, i need a jsp+mysql query to select data from two table for a perticular user eg:select data from employee and leave table for john.please help me
question
question  how do i select four late from data base.late represents 'L
question
question  I am doing a project using struts framework and spring jdbc .I have a issue that when data is inserted into database if we click the refresh button then the same data is again inserted in to the database.What
question
question  i need a jsp and mysql program to retrieve data from employee table and attendance table using user name and password at a time
question
question  i need to select data from database using mysql+java script+html   Please specify some more details
question
question  how to solve this problem com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect time value: ' 0:34:13 PM' for column 'afternoon' at row 1
question
question  Sir, Could You please send me Data Flow Diagrams(DFD) for " A DISTRIBUTED PROTOCOL TO SERVE DYNAMIC GROUPS FOR PEER-TO-PEER STREAMING

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.