DataFx 8 and jdbc and ResultSet Errors?

304 views
Skip to first unread message

Terry Rau

unread,
Nov 2, 2014, 1:56:08 AM11/2/14
to dataf...@googlegroups.com
Hi - I am curious why i am getting this error when testing out jdbc type connection with SQL server 2008. I'll get the results, but only 3 records of 4 are returned. and then i get the below error in a endless loop.


Nov 01, 2014 10:41:44 PM controllers.SampleController$1 convertOneRow
SEVERE: null
com.microsoft.sqlserver.jdbc.SQLServerException: The result set has no current row.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:190)
at com.microsoft.sqlserver.jdbc.SQLServerResultSet.verifyResultSetHasCurrentRow(SQLServerResultSet.java:483)
at com.microsoft.sqlserver.jdbc.SQLServerResultSet.getterGetColumn(SQLServerResultSet.java:2047)
at com.microsoft.sqlserver.jdbc.SQLServerResultSet.getValue(SQLServerResultSet.java:2082)
at com.microsoft.sqlserver.jdbc.SQLServerResultSet.getValue(SQLServerResultSet.java:2067)
at com.microsoft.sqlserver.jdbc.SQLServerResultSet.getString(SQLServerResultSet.java:2401)
at controllers.SampleController$1.convertOneRow(SampleController.java:64)
at controllers.SampleController$1.convertOneRow(SampleController.java:1)
at org.datafx.reader.converter.JdbcConverter.get(JdbcConverter.java:61)
at org.datafx.reader.JdbcSource.get(JdbcSource.java:141)
at org.datafx.provider.ListDataProvider$2.callTask(ListDataProvider.java:246)
at org.datafx.concurrent.PublishingTask.call(PublishingTask.java:57)
at org.datafx.concurrent.PublishingTask.call(PublishingTask.java:40)
at javafx.concurrent.Task$TaskCallable.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at javafx.concurrent.Service.lambda$null$436(Unknown Source)
at javafx.concurrent.Service$$Lambda$214/1722936940.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at javafx.concurrent.Service.lambda$executeTask$437(Unknown Source)
at javafx.concurrent.Service$$Lambda$212/150374210.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Here is my controller class.

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.datafx.controller.FXMLController;
import org.datafx.provider.ListDataProvider;
import org.datafx.reader.JdbcSource;
import org.datafx.reader.converter.JdbcConverter;

import model.Person;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;

@FXMLController("/application/Sample.fxml")
public class SampleController {

// final String sURL =
final String sURL = "jdbc:sqlserver://192.168.1.22:1433;databaseName=gregs_list;user=*****;password=*****";

final String sTableName = "PERSON";
final String sColumnFirstName = "FIRSTNAME";
final String sColumnLastName = "LASTNAME";
ObservableList<Person> myList = FXCollections.observableArrayList();

@FXML
TableView<Person> tblView;
@FXML
TableColumn<Person, String> colFirstName;
@FXML
TableColumn<Person, String> colLastName;

@FXML
public void ActionConnect(ActionEvent event) {
// Clear the Table View
myList.removeAll(myList);

connectData();

tblView.setItems(myList);
colFirstName
.setCellValueFactory(new PropertyValueFactory<Person, String>(
"firstName"));
colLastName
.setCellValueFactory(new PropertyValueFactory<Person, String>(
"lastName"));
}

private void connectData() {
JdbcConverter<Person> converter;
converter = new JdbcConverter<Person>() {
@Override
public Person convertOneRow(ResultSet rs) {
Person answer = new Person();
try {
answer.setFirstName(rs.getString(sColumnFirstName));
answer.setLastName(rs.getString(sColumnLastName));
return answer;
} catch (SQLException ex) {
Logger.getLogger(SampleController.class.getName()).log(
Level.SEVERE, null, ex);
}
return null;
}

};

JdbcSource<Person> dr = new JdbcSource<Person>(sURL, converter,
sTableName, sColumnFirstName, sColumnLastName);

ListDataProvider<Person> lodp = new ListDataProvider<>(dr);
lodp.setResultObservableList(myList);
lodp.retrieve();
}

}

I am using dependency...

 
<dependency>
<groupId>org.javafxdata</groupId>
<artifactId>datafx-core</artifactId>
<version>8.0b5</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.javafxdata</groupId>
<artifactId>datafx-datareader</artifactId>
<version>8.0b5</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.javafxdata</groupId>
<artifactId>datafx-samples</artifactId>
<version>8.0b5</version>
<type>jar</type>
</dependency>


It actually worked fine in version 2.0 without issues, but i wanted to play around with flow in latest version following some the tutorials. I am bit of a noob, so i apologize if I sound silly :P 


Hendrik Ebbers

unread,
Nov 3, 2014, 2:25:54 PM11/3/14
to dataf...@googlegroups.com
Hi,

first of all you should update your dependencies to DataFX 8.0 that was released as a final version some weeks ago. Here you need to reimport the DataFX classes because the package structure has changed to io.datafx
If the error is still there please let us know. In this case we will fix it.

Terry Rau

unread,
Nov 15, 2014, 6:19:22 PM11/15/14
to dataf...@googlegroups.com
Thank You! That did the trick, sorry I was confused with all the different dependencies :( - the only odd thing now, i have 4 records in the the table, but it only returns last 3 based on the connectData() method?

Terry Rau

unread,
Nov 16, 2014, 10:50:14 AM11/16/14
to dataf...@googlegroups.com
yeah, its kind of weird don't know if it has something to do with jdbc for mssql or something just skips the first recorded - i edited the table to have one row of data, and it returns nothing.

Johan Vos

unread,
Nov 20, 2014, 2:19:05 PM11/20/14
to dataf...@googlegroups.com
That seems like a bug.

I created an issue for it:
https://bitbucket.org/datafx/datafx/issue/52/jdbcconverter-skips-1-row

Thanks for reporting!

- Johan

Terry Rau

unread,
Nov 20, 2014, 3:07:40 PM11/20/14
to dataf...@googlegroups.com
Thanks, i was trying to troubleshoot, but i am such a noob - wasn't sure were it was faulting at. - Johan and Hendriks, I feel like i am chatting with Celebrities, its amazes me how much you guys know with programming, i am just scratching the surface and feel like i am so behind.

BTW - DataFX8 is such an amazing product - thanks for all your hard work and knowledge. plus all the other videos and tutorials I've been watching with Raspberry PI and JavaFx, and the Android and IOS porting.

Darko Čvagić

unread,
Nov 23, 2014, 4:59:47 AM11/23/14
to dataf...@googlegroups.com
I think I found the problem!
Post is in comment of your issue:
https://bitbucket.org/datafx/datafx/issue/52/jdbcconverter-skips-1-row

Johan Vos

unread,
Nov 26, 2014, 7:00:09 AM11/26/14
to dataf...@googlegroups.com
Thanks Darko and Terry, this is now fixed in the repository.

- Johan
Reply all
Reply to author
Forward
0 new messages