Conversion failed when converting the “invalid” value 'Residential' to data type int
How do I convert data that is given from result set string.
I am trying to show the drop down box gui as a text but give it a value of 1 and 2
what I want it to show as for drop down choice is right:
https://i.imgur.com/gDKAkDX.png
but I need the actual values to be 1 and 2 correspondingly
Then I need to put those values back into a database f key that only allows int...
final ObservableList options = FXCollections.observableArrayList();
public void fillComboBox()
Connection c;
try
Connection conn = null;
Statement stmt = null;
String queryx = "Select CusType_ID, CusTypeName from CustomerType";
ResultSet jrs = c.createStatement().executeQuery(queryx);
while (jrs.next())
String custyID = jrs.getString("CusType_ID");
String custyN = jrs.getString("CusTypeName");
options.add(new MyObject(custyID,custyN));
typeBox.setItems(options);
catch (SQLException e)
e.printStackTrace();
String sql = "INSERT INTO Customer [CustomerType_ID]) VALUES" typeBox.getValue() +"')";
java sql scenebuilder
add a comment |
How do I convert data that is given from result set string.
I am trying to show the drop down box gui as a text but give it a value of 1 and 2
what I want it to show as for drop down choice is right:
https://i.imgur.com/gDKAkDX.png
but I need the actual values to be 1 and 2 correspondingly
Then I need to put those values back into a database f key that only allows int...
final ObservableList options = FXCollections.observableArrayList();
public void fillComboBox()
Connection c;
try
Connection conn = null;
Statement stmt = null;
String queryx = "Select CusType_ID, CusTypeName from CustomerType";
ResultSet jrs = c.createStatement().executeQuery(queryx);
while (jrs.next())
String custyID = jrs.getString("CusType_ID");
String custyN = jrs.getString("CusTypeName");
options.add(new MyObject(custyID,custyN));
typeBox.setItems(options);
catch (SQLException e)
e.printStackTrace();
String sql = "INSERT INTO Customer [CustomerType_ID]) VALUES" typeBox.getValue() +"')";
java sql scenebuilder
add a comment |
How do I convert data that is given from result set string.
I am trying to show the drop down box gui as a text but give it a value of 1 and 2
what I want it to show as for drop down choice is right:
https://i.imgur.com/gDKAkDX.png
but I need the actual values to be 1 and 2 correspondingly
Then I need to put those values back into a database f key that only allows int...
final ObservableList options = FXCollections.observableArrayList();
public void fillComboBox()
Connection c;
try
Connection conn = null;
Statement stmt = null;
String queryx = "Select CusType_ID, CusTypeName from CustomerType";
ResultSet jrs = c.createStatement().executeQuery(queryx);
while (jrs.next())
String custyID = jrs.getString("CusType_ID");
String custyN = jrs.getString("CusTypeName");
options.add(new MyObject(custyID,custyN));
typeBox.setItems(options);
catch (SQLException e)
e.printStackTrace();
String sql = "INSERT INTO Customer [CustomerType_ID]) VALUES" typeBox.getValue() +"')";
java sql scenebuilder
How do I convert data that is given from result set string.
I am trying to show the drop down box gui as a text but give it a value of 1 and 2
what I want it to show as for drop down choice is right:
https://i.imgur.com/gDKAkDX.png
but I need the actual values to be 1 and 2 correspondingly
Then I need to put those values back into a database f key that only allows int...
final ObservableList options = FXCollections.observableArrayList();
public void fillComboBox()
Connection c;
try
Connection conn = null;
Statement stmt = null;
String queryx = "Select CusType_ID, CusTypeName from CustomerType";
ResultSet jrs = c.createStatement().executeQuery(queryx);
while (jrs.next())
String custyID = jrs.getString("CusType_ID");
String custyN = jrs.getString("CusTypeName");
options.add(new MyObject(custyID,custyN));
typeBox.setItems(options);
catch (SQLException e)
e.printStackTrace();
String sql = "INSERT INTO Customer [CustomerType_ID]) VALUES" typeBox.getValue() +"')";
java sql scenebuilder
java sql scenebuilder
edited Nov 10 at 3:52
asked Nov 10 at 1:10
a p
83
83
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
First create a class for storing the CusType_ID and CusTypeName in dropdown(combobox)
public class MyObject
private String key;
private String value;
public MyObject(String key, String value)
this.key = key;
this.text = value;
public String getKey()
return key ;
@Override
public String toString()
return value;
then store the value from your request
String queryx = "Select CusType_ID, CusTypeName from CustomerType";
ResultSet rs = c.createStatement().executeQuery(queryx);
while (rs.next())
int recordNumber = 1;
int recNumber =2;
String sx = rs.getString("CusTypeName");
String customerID = rs.getString("CusType_ID");
typeBox.addItem(new MyObject(customerID, sx));
Finally, get your value back from selected item and store it in your new sql
Object item = comboBox.getSelectedItem();
String value = ((MyObject)item).getKey();
String sql = "INSERT INTO Customer (CustomerType_ID) VALUES ("+
value +");" ;
I don't know why I am getting this error. ChoiceBox$ChoiceBoxSelectionModel cannot be cast to sample.MyObject, my comboBox is named typeBox
– a p
Nov 10 at 3:49
i Updated my code so you could better understand it, I also made that separate class like you made.
– a p
Nov 10 at 3:53
1
nvm I GOT IT. thank you so much. for some reason my call is different for the selection. It had to be Object item = typeBox.getSelectionModel().getSelectedItem();
– a p
Nov 10 at 4:00
I'm sorry for the late reply, did it worked? , if not it might you didn't choose the selected item --> String sql = "INSERT INTO Customer [CustomerType_ID]) VALUES" typeBox.getSelectedItem().getValue() +"')"; , please let me know if you want any think else
– Sari Masri
Nov 10 at 13:29
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53235174%2fconversion-failed-when-converting-the-invalid-value-residential-to-data-type%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
First create a class for storing the CusType_ID and CusTypeName in dropdown(combobox)
public class MyObject
private String key;
private String value;
public MyObject(String key, String value)
this.key = key;
this.text = value;
public String getKey()
return key ;
@Override
public String toString()
return value;
then store the value from your request
String queryx = "Select CusType_ID, CusTypeName from CustomerType";
ResultSet rs = c.createStatement().executeQuery(queryx);
while (rs.next())
int recordNumber = 1;
int recNumber =2;
String sx = rs.getString("CusTypeName");
String customerID = rs.getString("CusType_ID");
typeBox.addItem(new MyObject(customerID, sx));
Finally, get your value back from selected item and store it in your new sql
Object item = comboBox.getSelectedItem();
String value = ((MyObject)item).getKey();
String sql = "INSERT INTO Customer (CustomerType_ID) VALUES ("+
value +");" ;
I don't know why I am getting this error. ChoiceBox$ChoiceBoxSelectionModel cannot be cast to sample.MyObject, my comboBox is named typeBox
– a p
Nov 10 at 3:49
i Updated my code so you could better understand it, I also made that separate class like you made.
– a p
Nov 10 at 3:53
1
nvm I GOT IT. thank you so much. for some reason my call is different for the selection. It had to be Object item = typeBox.getSelectionModel().getSelectedItem();
– a p
Nov 10 at 4:00
I'm sorry for the late reply, did it worked? , if not it might you didn't choose the selected item --> String sql = "INSERT INTO Customer [CustomerType_ID]) VALUES" typeBox.getSelectedItem().getValue() +"')"; , please let me know if you want any think else
– Sari Masri
Nov 10 at 13:29
add a comment |
First create a class for storing the CusType_ID and CusTypeName in dropdown(combobox)
public class MyObject
private String key;
private String value;
public MyObject(String key, String value)
this.key = key;
this.text = value;
public String getKey()
return key ;
@Override
public String toString()
return value;
then store the value from your request
String queryx = "Select CusType_ID, CusTypeName from CustomerType";
ResultSet rs = c.createStatement().executeQuery(queryx);
while (rs.next())
int recordNumber = 1;
int recNumber =2;
String sx = rs.getString("CusTypeName");
String customerID = rs.getString("CusType_ID");
typeBox.addItem(new MyObject(customerID, sx));
Finally, get your value back from selected item and store it in your new sql
Object item = comboBox.getSelectedItem();
String value = ((MyObject)item).getKey();
String sql = "INSERT INTO Customer (CustomerType_ID) VALUES ("+
value +");" ;
I don't know why I am getting this error. ChoiceBox$ChoiceBoxSelectionModel cannot be cast to sample.MyObject, my comboBox is named typeBox
– a p
Nov 10 at 3:49
i Updated my code so you could better understand it, I also made that separate class like you made.
– a p
Nov 10 at 3:53
1
nvm I GOT IT. thank you so much. for some reason my call is different for the selection. It had to be Object item = typeBox.getSelectionModel().getSelectedItem();
– a p
Nov 10 at 4:00
I'm sorry for the late reply, did it worked? , if not it might you didn't choose the selected item --> String sql = "INSERT INTO Customer [CustomerType_ID]) VALUES" typeBox.getSelectedItem().getValue() +"')"; , please let me know if you want any think else
– Sari Masri
Nov 10 at 13:29
add a comment |
First create a class for storing the CusType_ID and CusTypeName in dropdown(combobox)
public class MyObject
private String key;
private String value;
public MyObject(String key, String value)
this.key = key;
this.text = value;
public String getKey()
return key ;
@Override
public String toString()
return value;
then store the value from your request
String queryx = "Select CusType_ID, CusTypeName from CustomerType";
ResultSet rs = c.createStatement().executeQuery(queryx);
while (rs.next())
int recordNumber = 1;
int recNumber =2;
String sx = rs.getString("CusTypeName");
String customerID = rs.getString("CusType_ID");
typeBox.addItem(new MyObject(customerID, sx));
Finally, get your value back from selected item and store it in your new sql
Object item = comboBox.getSelectedItem();
String value = ((MyObject)item).getKey();
String sql = "INSERT INTO Customer (CustomerType_ID) VALUES ("+
value +");" ;
First create a class for storing the CusType_ID and CusTypeName in dropdown(combobox)
public class MyObject
private String key;
private String value;
public MyObject(String key, String value)
this.key = key;
this.text = value;
public String getKey()
return key ;
@Override
public String toString()
return value;
then store the value from your request
String queryx = "Select CusType_ID, CusTypeName from CustomerType";
ResultSet rs = c.createStatement().executeQuery(queryx);
while (rs.next())
int recordNumber = 1;
int recNumber =2;
String sx = rs.getString("CusTypeName");
String customerID = rs.getString("CusType_ID");
typeBox.addItem(new MyObject(customerID, sx));
Finally, get your value back from selected item and store it in your new sql
Object item = comboBox.getSelectedItem();
String value = ((MyObject)item).getKey();
String sql = "INSERT INTO Customer (CustomerType_ID) VALUES ("+
value +");" ;
answered Nov 10 at 1:53
Sari Masri
1297
1297
I don't know why I am getting this error. ChoiceBox$ChoiceBoxSelectionModel cannot be cast to sample.MyObject, my comboBox is named typeBox
– a p
Nov 10 at 3:49
i Updated my code so you could better understand it, I also made that separate class like you made.
– a p
Nov 10 at 3:53
1
nvm I GOT IT. thank you so much. for some reason my call is different for the selection. It had to be Object item = typeBox.getSelectionModel().getSelectedItem();
– a p
Nov 10 at 4:00
I'm sorry for the late reply, did it worked? , if not it might you didn't choose the selected item --> String sql = "INSERT INTO Customer [CustomerType_ID]) VALUES" typeBox.getSelectedItem().getValue() +"')"; , please let me know if you want any think else
– Sari Masri
Nov 10 at 13:29
add a comment |
I don't know why I am getting this error. ChoiceBox$ChoiceBoxSelectionModel cannot be cast to sample.MyObject, my comboBox is named typeBox
– a p
Nov 10 at 3:49
i Updated my code so you could better understand it, I also made that separate class like you made.
– a p
Nov 10 at 3:53
1
nvm I GOT IT. thank you so much. for some reason my call is different for the selection. It had to be Object item = typeBox.getSelectionModel().getSelectedItem();
– a p
Nov 10 at 4:00
I'm sorry for the late reply, did it worked? , if not it might you didn't choose the selected item --> String sql = "INSERT INTO Customer [CustomerType_ID]) VALUES" typeBox.getSelectedItem().getValue() +"')"; , please let me know if you want any think else
– Sari Masri
Nov 10 at 13:29
I don't know why I am getting this error. ChoiceBox$ChoiceBoxSelectionModel cannot be cast to sample.MyObject, my comboBox is named typeBox
– a p
Nov 10 at 3:49
I don't know why I am getting this error. ChoiceBox$ChoiceBoxSelectionModel cannot be cast to sample.MyObject, my comboBox is named typeBox
– a p
Nov 10 at 3:49
i Updated my code so you could better understand it, I also made that separate class like you made.
– a p
Nov 10 at 3:53
i Updated my code so you could better understand it, I also made that separate class like you made.
– a p
Nov 10 at 3:53
1
1
nvm I GOT IT. thank you so much. for some reason my call is different for the selection. It had to be Object item = typeBox.getSelectionModel().getSelectedItem();
– a p
Nov 10 at 4:00
nvm I GOT IT. thank you so much. for some reason my call is different for the selection. It had to be Object item = typeBox.getSelectionModel().getSelectedItem();
– a p
Nov 10 at 4:00
I'm sorry for the late reply, did it worked? , if not it might you didn't choose the selected item --> String sql = "INSERT INTO Customer [CustomerType_ID]) VALUES" typeBox.getSelectedItem().getValue() +"')"; , please let me know if you want any think else
– Sari Masri
Nov 10 at 13:29
I'm sorry for the late reply, did it worked? , if not it might you didn't choose the selected item --> String sql = "INSERT INTO Customer [CustomerType_ID]) VALUES" typeBox.getSelectedItem().getValue() +"')"; , please let me know if you want any think else
– Sari Masri
Nov 10 at 13:29
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53235174%2fconversion-failed-when-converting-the-invalid-value-residential-to-data-type%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown