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



Home Answers Viewqa JDBC Data base related question
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


raja
Data base related question
1 Answer(s)      4 years and a month 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.


Advertisement
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
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
Advertisements
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
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 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
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
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
Java and jvm related question
Java and jvm related question  What is difference between java data types and jvm data types
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 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 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  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
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
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‚
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
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
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
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
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
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
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
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
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
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
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
Advertisements
 

 

 

DMCA.com