AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

problem in randomly fetching data from mssql databse using s

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java and Databases
View previous topic :: View next topic  
Author Message
Praveen homkar via JavaKB
Guest





PostPosted: Mon Mar 14, 2005 2:39 pm    Post subject: problem in randomly fetching data from mssql databse using s Reply with quote



Hi all
i have a gui based application which conects a MSSQL-server 2000.

I have buttons such as first-previous-next-last buttons to navigate
throught the database. I am using scrollable resultset
st=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);

i want to fetch a particualr row based on the primary key passed.

i am incrementing a number whenever user presses next button.

I am using rs.absolute();

but its giving invalid cursor state error.

Please help me with some code that allows fast and random navigation

i am using type 1 driver(jdbc-odbc) bridge)

--
Message posted via http://www.javakb.com
Back to top
joeNOSPAM@BEA.com
Guest





PostPosted: Mon Mar 14, 2005 5:24 pm    Post subject: Re: problem in randomly fetching data from mssql databse usi Reply with quote



Hi. You have no reason to continue using the jdbc-odbc bridge. It is
buggy and unsupported. At the very least you should use the JDBC
driver that MS provides for free. Unless you are going to try to
update rows through the result set, don't use UPDATEABLE.

Joe Weinstein at BEA

Back to top
Praveen homkar via JavaKB
Guest





PostPosted: Tue Mar 15, 2005 4:23 am    Post subject: Re: problem in randomly fetching data from mssql databse usi Reply with quote



hi Joe Weinstein, thanks for the reply


I am using jdbc-odbc bridge so that user can use any database and just he
has to enter DSN in settings.

using the first-prev-next-last buttons user can navigate through the
records and i have provided with a save button which updates that
particulkar record,that is why i am using updatable resultset.

at present the problem is that the databse resides in a server,so when i
press next button it is taking 8-9 seconds to return the record.

Thats why i want to use rs.next()or rs.absolute() when user presses next
button,but i am getting invalid cursor state error.

I just want to know how to correctly use these functions and avoid the
above error, Please help

--
Message posted via http://www.javakb.com
Back to top
Praveen homkar via JavaKB
Guest





PostPosted: Tue Mar 15, 2005 6:19 am    Post subject: Re: problem in randomly fetching data from mssql databse usi Reply with quote

Hi joe i am sending u piece of my code



Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con= DriverManager.getConnection(url);//I am using working url

st= con.createStatement
(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);

rs=st.executeQuery("Select * from ansidata ");

//////// i have a counter which i am passing when user clicks on
next/previous button i am calling the following method with passing it as
parameter

but the problem is rs.absolute() is not making any difference(it is
returning false).


public static String getResultSet(int rec_No)
{
String result=" ";

try
{

rs.absolute(rec_No);

metadata=rs.getMetaData();


for(int i=1;i<=metadata.getColumnCount();i++)
{
if(i==1)
result=rs.getString(i);
else
{
String fieldValue=rs.getString(i);

if(fieldValue==null)
fieldValue="";
result=result+","+fieldValue;

}


}


}


catch(Exception e)
{
e.printStackTrace();
return("no_record");
}


return result;



}

--
Message posted via http://www.javakb.com
Back to top
Praveen homkar via JavaKB
Guest





PostPosted: Tue Mar 15, 2005 8:48 am    Post subject: Re: problem in randomly fetching data from mssql databse usi Reply with quote

The problem of rs.absolute() is solved

the problem was i was changing my result set somewhere in code


but the only problem is it is taking more time to fetch data from server
when i press nect button.

how can i improve the performance

--
Message posted via http://www.javakb.com
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java and Databases All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.