I have another problem with cassandra.. I have export a table in Mysql in .csv format and import it in Cassandra.the Mysql table contains filds date and time of types Date and Time. I define these fields as varchar in cassandra. so when I import the .csv file and execute the below query, it shows me an error:
my query:
ResultSet rs = stmnt.ExecuteQuery("Select * from station info where IDstation = 1011 and IDinfo = 18412:);
while (rs.next) {
System.out.println(rs1.getFloate(1) + " " +
rs1.getString(2) + " " +
rs1.getFloate(3) + " " +
rs1.getString(4) + " " +
rs1.getInt(5) + " " +
rs1.getInt(6) + " " +
rs1.getString(7) + " " +
rs1.getFloate(8));
}
the 7th field in print command is date..
and the error is:
java.lang.NumberFormatException: For input String: "6/2/1962"
at org.apache.cassandracql.jdbc.cassandraResultSet.getInt(CassandraResultSet.java:619)
at org.apache.cassandracql.jdbc.cassandraResultSet.getInt(CassandraResultSet.java:590)
I can not understand what it says... can anyone help me please?
Read what the stacktrace is telling you carefully
java.lang.NumberFormatException: For input String: "6/2/1962"
at org.apache.cassandracql.jdbc.cassandraResultSet.getInt(CassandraResultSet.java:619)
at org.apache.cassandracql.jdbc.cassandraResultSet.getInt(CassandraResultSet.java:590)
The error you are getting is to do with an attempt to retrieve a string as a integer.
Make sure that the date column is coming at 7th position only and not anywhere else. I suggest you to improve your query by specifying the column names. For eg.,
SELECT Col1, Col2... FROM Table
This avoids confusion of column order.
Related
I am creating a message inside a string using a Script task
The code would look like this:
Message = Description +"\n" + Message;
The idea is to receive a message like this:
Description
Description
and so on
Within a messagebox I can see this result, but when I open the mail, the message is composed of one single line:
Description1 Description2
I have also changed "\n" for "\n\r", Environment.NewLine. But it didn't work.
Could you explain me what am I doing wrong?
You need to typecast it as below:
(DT_STR,2,1252)"\r\n"
For example...the below expression in Execute SQL task is dynamic SQL
"INSERT INTO [dbo].[OBJ_COUNT]([OBJ_NAME], [OBJ_COUNT]) VALUES ( " + "'EMPLOYEE_MASTER', " + (DT_STR, 10, 1252) (#[User::EMP_MAST_COUNT])+" );" + (DT_STR,2,1252)"\r\n" + "GO " + (DT_STR,2,1252)"\r\n" + "INSERT INTO [dbo].[OBJ_COUNT]([OBJ_NAME], [OBJ_COUNT]) VALUES ( " + "'DEPT_MASTER', " + (DT_STR, 10, 1252) (#[User::DEPT_MAST_COUNT])+" );" + (DT_STR,2,1252)"\r\n"+ "GO "
And will give output as below...
INSERT INTO [dbo].[OBJ_COUNT]([OBJ_NAME], [OBJ_COUNT]) VALUES ( 'EMPLOYEE_MASTER', 2514);
GO
INSERT INTO [dbo].[OBJ_COUNT]([OBJ_NAME], [OBJ_COUNT]) VALUES ( 'DEPT_MASTER', 2541);
GO
Try "\n\n" . This works but adds an extra line break. In most cases it is adequate.
During a Value-Change inside a browse, my string value suddenly changes, specifically the string(9) will change to string(0).
sample:
in my combo-box, i used a list-item-pair with following code:
cb-name:LIST-ITEM-PAIRS = ?.
cb-name:DELIMITER = '?'.
FOR EACH employee WHERE employee.date-resigned = ? NO-LOCK BY employee.employee-no.
cb-name:ADD-LAST(TRIM(STRING(employee.employee-no, '99999999') + " - " + employee.last-name + ", " + employee.first-name + " " + SUBSTRING(employee.middle-name,1,1)) + ".",employee.employee-no).
END.
cb-name:SCREEN-VALUE = cb-name:ENTRY(1).
in the value-changed of browse:
ASSIGN cb-name:SCREEN-VALUE =
STRING(TRIM(STRING(employee.employee-no, '99999999') + " - " + employee.last-name + ", " + employee.first-name + " " + SUBSTRING(employee.middle-name,1,1)) + "." ,
STRING(employee.employee-no, '99999999')).
if the employee no has a string value of 9, progress will change it to 0.. producing an error message that has an invalid value..
ex: from 819001 /*correct*/ to 810001 /*incorrect*/
if there is no string(9), it will display like:818002
if i message the STRING(employee.employee-no, '99999999')), it will display the correct string value
Version doesn't matter in this case, apparently. I just simulated it in 10.2B08 using a temp-table with the named tables. The problem is when you're assigning the screen-value to the combo you're trying to convert the whole string (employee-no + names + separators) into format 99999999.
Since your combo is list-item-pairs
('Whatever I want it to display','the real value',
'and so on display' , 'and so forth value')
your solution is to assign the screen value just to the real value, disregard the label. In other words, as simple as changing your value-changed code to
ASSIGN cb-name:SCREEN-VALUE = STRING(employee.employee-no, '99999999') .
It worked for me. Let me know if you are still having trouble with it.
I have two questions:
1. If we can pass an array to VBSCript using java. I am able to pass single variables to VBSCript using following command
Runtime.getRuntime().exec("wscript openChartsDevice.vbs " + fileName + " " + range);
But when I pass a String array, it says type mismatch. I am catching the array passed in
Dim arr()
any Suggestions?
Edit 1 Following question has been answered
2. I am using following Vbscript to create chart in excel
Dim oExl,excelPath,objWriteSheet,objWriteWorkbook
Dim oMychartProcs
Set oExl=CreateObject("Excel.Application")
Set objWriteWorkbook = oExl.Workbooks.Open("SomeExcelfile.xlsx")
Set objWriteSheet = objWriteWorkbook.Worksheets(1)
Set oMychartProcs = objWriteWorkbook.Charts.Add
oMychartProcs.SetSourceData objWriteSheet.Range(Cells(2,1),Cells(7,6))
oMychartProcs.ChartType = 4
oMychartProcs.Name = "ChartName"
oMychartProcs.Activate
I have given the range as A2:F7. when I enter
oMychartProcs.SetSourceData objWriteSheet.Range("A2:F7")
the chart is created perfectly but when I use the
Range(Cells(2,1),Cells(7,6))
whole excel sheet is converted to chart.
I want to provide the range through parameters so I want above formula to work. I've searched a lot and could not find a definitive way for it. Thank you.
You can not pass array as an object. But you can pass its elements as string parameters to the vbscript function with a space as the delimiter.
openChartsDevice.vbs " + fileName + " " + arg[0] + " " + arg[1] + " " + arg[2].....
You can a create a method in java to pass an array and return a string
arg[0] + " " + arg[1] + " " + arg[2].....
Another Approach: Create a file with input parameters. Update your VBScript to refer to that input file to get the parameters instead of looking for command line arguments.
I don't know JScript. But the way to get in VBScript the same thing.
For Each thing in Array()
A = A & thing & " "
Next
You are actually asking how to turn an array into a delimited string not a vbscript array.
See this article which your question title implies you are interested in.
http://blogs.msdn.com/b/ericlippert/archive/2003/09/22/53061.aspx
I'm trying to solve an issue I have when I'm trying to use OLE DB for reading Excel files.
I found that the problem is because there is a hash mark (#) in the sheet name.
Unfortunately, I can't rename the sheet.
So after some tries, I've succeeded to read a full sheet by adding quotation marks ('):
Before
Select * from [" + sheetName + "$];
After (working)
Select * from ['" + sheetName + "$'];
But then I got stuck when trying to read a range from the sheet with the OLE DB feature:
Select * from [" + sheetName + "$" + fromCell + ":" + toCell + "];
When I try to send this command, it's seems like the # is replaced by . and then it cannot find the sheet.
I've tried many combination and escape codes and didn't find any solution. How can I access this file?
Your final output should look like this
'MySheet$A1:B2'
So your select should be
var SheetName = "MySheet";
var fromCell = "A1";
var toCell = "B2";
var sql = "Select * from ['" + SheetName + "$" + fromCell + ":" + toCell + "']";
Console.WriteLine(sql);
// Output
// Select * from ['MySheet$A1:B2']
Also consider parametrising your sql for better readability and also preventing sql code injection. You can find a guide for how to do it at OleDbCommand.Parameters.
this code is in Textbox Change event.
dds.Tables["IncomeGenerator"].DefaultView.RowFilter = "' Income LIKE '" + txtSearch.Text + "' OR Expenses LIKE '" + txtSearch.Text + "' OR Date LIKE '" + txtSearch.Text + "' OR Balance LIKE '" + txtSearch.Text + "' OR Description LIKE '" + txtSearch.Text + "'";
when i run it, it gives a error saying " The expression contains an invalid string constant: '. "
can someone help me.
my Income, Expenses and Balance is Data Type Float and Date is Datetime. i hope it may help. can someone guide me with the mistake and help me
It's hard to tell for sure, but sometimes when I copy code from a web page or word processor, I inadvertently include a "book quote" (http://en.wikipedia.org/wiki/Quotation_mark_glyphs) that screws things up.
It looks like there may be some in the sample you posted. Try making sure all the quotes are the straight-up-and-down quotes, and not the begin-end "book quotes".