Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Invalid operation for the current cursor position.

Author  Topic 

Bhaarat
Starting Member

3 Posts

Posted - 2004-06-25 : 11:00:14
hi i posted this in general forum but got no replies as yet. May be i was suppose to post it here
Hi every one,
I am new to SQL. so please bare with me.

All i am trying to do right now is getting the data from SQL database to my java program using JDBC driver. I am using MS SQL 2000. whenever i run my program i get this error Invalid operation for the current cursor position. In my database all i have is one column named ProName, and one row thats all..its a sample databse i just wanted to see if it works. Here is my code
/* This program reads the queries and gets all the cd labels */
import javax.sql.*;
import javax.naming.*;
import java.sql.*;
import java.awt.*;
import java.applet.*;
import java.applet.Applet;
import java.awt.event.*;
public class kioskSW extends Frame implements ActionListener
{
CheckboxGroup cdNames = new CheckboxGroup();
String Name;
Checkbox cb;
int counter;
Button more = new Button ("More");
public static void main (String args[])
{
//setLayout(new GridLayout (22,1));
try
{
// Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
//jdbc:odbc:KioskDB
// Connection conn = DriverManager.getConnection("jdbc:odbc:kiosk","","");
//jdbc:microsoft:sqlserver://131.118.162.88\\KioskDB:1433
// Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url = "jdbc:microsoft:sqlserver://127.0.0.1:1433;database=KioskDB";
Connection conn = DriverManager.getConnection (url,"sa","");
Statement stmt = conn.createStatement();
ResultSet rs;

rs = stmt.executeQuery ("SELECT * "+" FROM KioskDB.dbo.Table1");
String Name = rs.getString("ProName");
//System.out.println(Name);
/*while ((rs.next()) && (counter < 20))
{
Name = rs.getString("ProName");
cb = new Checkbox(Name,cdNames,false);
add("West",cb);
counter++;
}*/
}

catch (Exception e)
{
System.out.println("Got an Exception");
System.out.println(e.getMessage());
e.printStackTrace();

}

//add(more);
}
public void actionPerformed (ActionEvent e)
{}
}

ps - do i need to do somethin else if i want to run this in applet? because when i run it in applet it gives me error establishing socket error.
Bhaarat (newbe)

Aim high

Aim high
   

- Advertisement -