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 questionData 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 questionproject
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 Questionsdata 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 HibernateQuestion related to Hibernate Why do we use Set in child class in 1:many hibernate ,why can't we use Directly HashSet
Struts related QuestionStruts
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 objectsjava
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 questionjava
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 QuestionJava
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 questionstring
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 questionRestlet 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 stringjava 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 jobsdata 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 coursesdata 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 sciencejobs
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 analyticscourses
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 basedata 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 BASEDATA 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 ConnectivityData 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
JSP data base validationJSP
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 mysqlretrieve
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 - JDBCData 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
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
iphone property list relatediphone 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
for store data in data base - JSP-Servletfor 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
Retrieving data from data base using jsp combo boxRetrieving
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
related to databaserelated to database how to override existing values in table?
when user enters his updated
data through query
questionquestion 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
questionquestion 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
questionquestion 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
questionquestion 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 questionquestion 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
Related QuestionsRelated 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 ValueStruts2 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 ValueStruts2 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