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 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 Tutorials/Questions & Answers:
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
Advertisements
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
question related to overloading
question related to overloading  what is difference between function overloading & method overloading
question related to overloading
question related to overloading  what is difference between function overloading & method overloading
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
Java and jvm related question
Java and jvm related question  What is difference between java data types and jvm data types
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
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
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â
data science related jobs
data science related jobs  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: data science... learn the topic "data science related jobs". Also tell me which
data related courses
data related courses  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: data related... the topic "data related courses". Also tell me which is the good training
jobs related to data science
jobs related to data science  Hi, I am beginner in Data Science... related to data science Try to provide me good examples or tutorials links so that I can learn the topic "jobs related to data science". Also tell me
courses related to data analytics
courses related to data analytics  Hi, I am beginner in Data Science...: courses related to data analytics Try to provide me good examples or tutorials links so that I can learn the topic "courses related to data analytics"
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
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
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
Java Related Question
Java Related Question
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
retrieve related data from database using jsp and mysql
retrieve related data from database using jsp and mysql  Hi sir, please give some example of jsp code for retrieving mysql database values in multiple dropdown list. if we change a value in a dropdown its related value must
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
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
Display related data in other drop down list on selecting one data in one drop down list
Display related data in other drop down list on selecting one data in one drop down list  How to display related datas in dropdown list from database on selecting one data in previous dropdownlist in Java Server Page
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
ModuleNotFoundError: No module named 'odoo10-addon-l10n-br-data-base'
ModuleNotFoundError: No module named 'odoo10-addon-l10n-br-data-base' ...: No module named 'odoo10-addon-l10n-br-data-base' How to remove the ModuleNotFoundError: No module named 'odoo10-addon-l10n-br-data-base' error
ModuleNotFoundError: No module named 'odoo8-addon-l10n-br-data-base'
ModuleNotFoundError: No module named 'odoo8-addon-l10n-br-data-base'  ...: No module named 'odoo8-addon-l10n-br-data-base' How to remove the ModuleNotFoundError: No module named 'odoo8-addon-l10n-br-data-base' error
Question about "Insert text file data into Database"
Question about "Insert text file data into Database"  Hey I was reading the tutorial "Insert text file data into Database", (awesome btw), and noticed that both a FileInputStream, a DataInputStream and a BufferedReader
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
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
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
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
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
related to database
related to database  how to override existing values in table? when user enters his updated data through query
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
What is the average base salary of a Data Scientist reported by The New York Times?
What is the average base salary of a Data Scientist reported by The New York Times?  Hi, I am beginner in Data Science and machine learning field. I... base salary of a Data Scientist reported by The New York Times?". Also tell
Related Questions
Related Questions  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: Related Questions... "Related Questions". Also tell me which is the good training courses
Struts2 and Hibernate Fetch Data Base Value
Struts2 and Hibernate Fetch Data Base Value  Hello Sir, I am...;AdminProvideLeave>(); try { > Query q = session.createQuery("from >...;AdminLeavePojo> adlp = null; > try { Query q = > session.createQuery
Struts2 and Hibernate Fetch Data Base Value
Struts2 and Hibernate Fetch Data Base Value  Hello Sir, I am...;AdminProvideLeave>(); try { > Query q = session.createQuery("from >...;AdminLeavePojo> adlp = null; > try { Query q = > session.createQuery

Ads