Select a field with multiple where clause - where-clause

I need to select a field with multiple where clause. The below query causes a syntax error.
String selectquery="SELECT" +KEY_EXPAMT+ "FROM" +TABLE_EXP+ "WHERE"
+KEY_EXPCAT+ "='" +String.valueOf(cat)+ "'AND " +KEY_EXPMONTH+ "='"
+String.valueOf(month)+ "' AND " +KEY_EXPYEAR+ "='" +String.valueOf(year)+ "'
AND " +KEY_EXPFROM+ "='" +String.valueOf(from)+"'";
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(selectquery, new String[]{cat, month,year,from});
logcat:
03-20 15:01:36.606 19106-19125/com.expense.javed.expensetrackingsystem D/OpenGLRenderer﹕ Render dirty regions requested: true
03-20 15:01:36.623 19106-19106/com.expense.javed.expensetrackingsystem D/Atlas﹕ Validating map...
03-20 15:01:36.680 19106-19125/com.expense.javed.expensetrackingsystem I/Adreno-EGL﹕ : EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_LA.BF.1.1.04.04.02.162.107_msm8226_LA.BF.1.1__release_AU ()
OpenGL ES Shader Compiler Version: E031.25.01.03
Build Date: 10/28/14 Tue
Local Branch:
Remote Branch: quic/l_LNX.LA.3.6
Local Patches: NONE
Reconstruct Branch: AU_LINUX_ANDROID_LA.BF.1.1.04.04.02.162.107 + cb93e16 + f50fe49 + d7c18e6 + 5b9a565 + 0f3a25d + 607156e + 75511aa + e4d16c0 + 686f3eb + 211a271 + dd281ee + NOTHING
03-20 15:01:36.683 19106-19125/com.expense.javed.expensetrackingsystem I/OpenGLRenderer﹕ Initialized EGL, version 1.4
03-20 15:01:36.762 19106-19125/com.expense.javed.expensetrackingsystem D/OpenGLRenderer﹕ Enabling debug mode 0
03-20 15:01:48.482 19106-19106/com.expense.javed.expensetrackingsystem I/Choreographer﹕ Skipped 30 frames! The application may be doing too much work on its main thread.
03-20 15:01:48.494 19106-19125/com.expense.javed.expensetrackingsystem V/RenderScript﹕ Application requested CPU execution
03-20 15:01:48.507 19106-19125/com.expense.javed.expensetrackingsystem V/RenderScript﹕ 0xb862fc90 Launching thread(s), CPUs 4
03-20 15:02:13.932 19106-19106/com.expense.javed.expensetrackingsystem E/SQLiteLog﹕ (1) near "SELECTexpenseamountFROMexpenseWHEREexpensecategory": syntax error
03-20 15:02:13.946 19106-19106/com.expense.javed.expensetrackingsystem D/AndroidRuntime﹕ Shutting down VM
03-20 15:02:13.962 19106-19106/com.expense.javed.expensetrackingsystem E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.expense.javed.expensetrackingsystem, PID: 19106
android.database.sqlite.SQLiteException: near "SELECTexpenseamountFROMexpenseWHEREexpensecategory": syntax error (code 1): , while compiling: SELECTexpenseamountFROMexpenseWHEREexpensecategory='food'AND expensemonth='march' AND expenseyear='2015' AND expensefrom='InBank'
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteQuery.(SQLiteQuery.java:37)
at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1316)
at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1255)
at com.expense.javed.expensetrackingsystem.SqlLiteDb.updateExpense(SqlLiteDb.java:122)
at com.expense.javed.expensetrackingsystem.ExpensingAmountActivity$4$1.onClick(ExpensingAmountActivity.java:145)
at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:160)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5312)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)
03-20 15:02:15.674 19106-19106/com.expense.javed.expensetrackingsystem I/Process﹕ Sending signal. PID: 19106 SIG: 9
03-20 15:02:16.502 20366-20387/com.expense.javed.expensetrackingsystem D/OpenGLRenderer﹕ Render dirty regions requested: true
03-20 15:02:16.518 20366-20366/com.expense.javed.expensetrackingsystem D/Atlas﹕ Validating map...
03-20 15:02:16.576 20366-20387/com.expense.javed.expensetrackingsystem I/Adreno-EGL﹕ : EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_LA.BF.1.1.04.04.02.162.107_msm8226_LA.BF.1.1__release_AU ()
OpenGL ES Shader Compiler Version: E031.25.01.03
Build Date: 10/28/14 Tue
Local Branch:
Remote Branch: quic/l_LNX.LA.3.6
Local Patches: NONE
Reconstruct Branch: AU_LINUX_ANDROID_LA.BF.1.1.04.04.02.162.107 + cb93e16 + f50fe49 + d7c18e6 + 5b9a565 + 0f3a25d + 607156e + 75511aa + e4d16c0 + 686f3eb + 211a271 + dd281ee + NOTHING
03-20 15:02:16.578 20366-20387/com.expense.javed.expensetrackingsystem I/OpenGLRenderer﹕ Initialized EGL, version 1.4
03-20 15:02:16.609 20366-20387/com.expense.javed.expensetrackingsystem D/OpenGLRenderer﹕ Enabling debug mode 0

Don't do that. Your code is vulnerable to an SQL injection attack. You should really use prepared statements with ? placeholders for the values, and then set the values later. Or, at a minimum, you should escape the strings properly. To learn about SQL injection, see http://en.wikipedia.org/wiki/SQL_injection
However, as for your error, I think this says it all:
"SELECTexpenseamountFROMexpenseWHEREexpensecategory='food'AND expensemonth='march' AND expenseyear='2015' AND expensefrom='InBank'"
You are missing spaces in your query.

Related

I am getting EXC_GUARD when launching app using NSTask launchedTaskWithLaunchPath

Faulting code:
myTask = [NSTask launchedTaskWithLaunchPath: appPath arguments: initArray];
Where myTask is a global static NSTask* myTask = NULL; and initArray is a global static NSMutableArray *initArray = NULL; and appPath is a local NSString*
Exception Type: EXC_GUARD
Exception Codes: 0x4000000200000001, 0x326e91a2a5c769eb
Exception Subtype: GUARD_TYPE_FD, id=0x326e91a2a5c769eb, fd=1, flavor=0x00000002 (DUP)
Top of stack:
0 libsystem_kernel.dylib 0x00007fff2033848e dup + 10
1 com.apple.Foundation 0x00007fff2126df14 -[NSConcreteTask launchWithDictionary:error:] + 2491
2 com.apple.Foundation 0x00007fff21294c89 +[NSTask launchedTaskWithLaunchPath:arguments:] + 146
This issue is not reproducible and this code has not been changed since years. Please suggest some ways to debug this.
Additional info: Parent app which is launching this task has its output stream and error stream set to a log file but both the streams have been set after this app gets launched.

codename one push notification meet error "javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure"

We have a web project which is always working fine, it just using codename one push api to push notification to our devices, but it suddenly get the following error:
javax.net.ssl.SSLHandshakeException: Received fatal alert:
handshake_failure
Below is the core code (same with codenamoe one demo)
HttpURLConnection connection = (HttpURLConnection)new URL("https://push.codenameone.com/push/push").openConnection();
connection.setDoOutput(true);
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
String cert = ITUNES_DEVELOPMENT_PUSH_CERT;
String pass = ITUNES_DEVELOPMENT_PUSH_CERT_PASSWORD;
if(ITUNES_PRODUCTION_PUSH) {
cert = ITUNES_PRODUCTION_PUSH_CERT;
pass = ITUNES_PRODUCTION_PUSH_CERT_PASSWORD;
}
String query = "token=" + PUSH_TOKEN +
"&device=" + URLEncoder.encode(deviceId1, "UTF-8") +
"&device=" + URLEncoder.encode(deviceId2, "UTF-8") +
"&device=" + URLEncoder.encode(deviceId3, "UTF-8") +
"&type=1" +
"&auth=" + URLEncoder.encode(FCM_SERVER_API_KEY, "UTF-8") +
"&certPassword=" + URLEncoder.encode(pass, "UTF-8") +
"&cert=" + URLEncoder.encode(cert, "UTF-8") +
"&body=" + URLEncoder.encode(MESSAGE_BODY, "UTF-8") +
"&production=" + ITUNES_PRODUCTION_PUSH +
"&sid=" + URLEncoder.encode(WNS_SID, "UTF-8") +
"&client_secret=" + URLEncoder.encode(WNS_CLIENT_SECRET, "UTF-8");
try (OutputStream output = connection.getOutputStream()) {
output.write(query.getBytes("UTF-8"));
}
int c = connection.getResponseCode();
// read response JSON
I directly run the code in unit test, it works well.
But when I call the function from project (such as a button from webpage), the error happened.
I tried several way to solve it but still can not work, please give me some suggestion to fix the issue. Thank you!
This generally happens if the certificate is invalid or out of date etc. It can happen if your connection. I just verified our SSL certificate on the push servers and it's valid (generated by cloudflare) so I suggest checking the routes to the server and your version of Java. You should have Java 8 or newer with a recent enough minor update version.

"Output file stream not open": Error while running SE for X86 using gem5

I'm trying to run a SE simulation for x86 platform. Whenever I run the sample command on the website, but it doesn't work
The error log is as follows:
gem5.opt: build/X86/base/output.cc:93: OutputFile<StreamType>::OutputFile(const OutputDirectory&, const string&, std::ios_base::openmode, bool) [with StreamType = std::basic_ofstream<char>; std::__cxx11::string = std::__cxx11::basic_string<char>; std::ios_base::openmode = std::_Ios_Openmode]: Assertion `_fstream->is_open()' failed.
Program aborted at tick 0
--- BEGIN LIBC BACKTRACE ---
build/X86/gem5.opt(_Z15print_backtracev+0x15)[0x16d8065]
build/X86/gem5.opt(_Z12abortHandleri+0x39)[0x16e8989]
/lib64/libpthread.so.0[0x390200f7e0]
/lib64/libc.so.6(gsignal+0x35)[0x3901832495]
/lib64/libc.so.6(abort+0x175)[0x3901833c75]
/lib64/libc.so.6[0x390182b60e]
/lib64/libc.so.6(__assert_perror_fail+0x0)[0x390182b6d0]
build/X86/gem5.opt(_ZN15OutputDirectory4openERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt13_Ios_Openmodebb+0x281)[0xa8ed01]
build/X86/gem5.opt(_ZN5Stats8initTextERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb+0x3f)[0xaaef9f]
build/X86/gem5.opt[0x16bdde0]
build/X86/gem5.opt[0x99f9e1]
build/X86/gem5.opt(PyEval_EvalFrameEx+0x7cf3)[0x180e6e3]
build/X86/gem5.opt(PyEval_EvalCodeEx+0x89c)[0x180ff6c]
build/X86/gem5.opt[0x188502e]
build/X86/gem5.opt(PyObject_Call+0x3a)[0x177e29a]
build/X86/gem5.opt(PyEval_EvalFrameEx+0xe76)[0x1807866]
build/X86/gem5.opt(PyEval_EvalCodeEx+0x89c)[0x180ff6c]
build/X86/gem5.opt(PyEval_EvalFrameEx+0x6318)[0x180cd08]
build/X86/gem5.opt(PyEval_EvalFrameEx+0x641a)[0x180ce0a]
build/X86/gem5.opt(PyEval_EvalCodeEx+0x89c)[0x180ff6c]
build/X86/gem5.opt(PyEval_EvalFrameEx+0x6318)[0x180cd08]
build/X86/gem5.opt(PyEval_EvalCodeEx+0x89c)[0x180ff6c]
build/X86/gem5.opt(PyEval_EvalCode+0x19)[0x1810059]
build/X86/gem5.opt(PyRun_StringFlags+0xf5)[0x1837db5]
build/X86/gem5.opt(_Z6m5MainiPPc+0x5f)[0x16e74bf]
build/X86/gem5.opt(main+0x38)[0x7410d8]
/lib64/libc.so.6(__libc_start_main+0xfd)[0x390181ed1d]
build/X86/gem5.opt[0x766d31]
--- END LIBC BACKTRACE ---
Abort

Issue with obtaining the offline messages using openfire server

Offline messages are not delivering to the user when the person avails.
DelayInformation info = (DelayInformation)message.getExtension("x","jabber:x:delay");
returns null.
when i iterate the collection of message.getExtensions() , i get delay urn:xmpp:delay.
can anyone explain on this.
I'm using smack and smackx.jar. Though the smackx.jar has smack.providers it's not taken into account.
some suggested to use urn:xmpp:delay ,which results in class cast exception.
DelayInformation inf = (DelayInformation)message.getExtension("delay","urn:xmpp:delay");
Exception:
java.lang.ClassCastException: org.jivesoftware.smack.packet.DefaultPacketExtension
if this is for android by using the Smack Library try this:
ExtensionElement delay = message.getExtension("urn:xmpp:delay");
if(message.getExtension("urn:xmpp:delay") != null){
Log.i("RECVEIVED", "delay 1: " + delay.toXML());
Log.i("RECVEIVED", "delay 2: " + delay.getNamespace());
Log.i("RECVEIVED", "delay 3: " + delay.getElementName());
}
Log output:
I/RECVEIVED: delay 1: <delay xmlns='urn:xmpp:delay' stamp='2017-07-31T04:09:23.224+00:00' from='81.89.100.197'></delay>
I/RECVEIVED: delay 2: urn:xmpp:delay
I/RECVEIVED: delay 3: delay
this is another possibillity:
DelayInformation delayInformation = DelayInformation.from(message);
if (delayInformation != null) {
Log.i("RECVEIVED", "delay 1 : " + delayInformation.getStamp());
Log.i("RECVEIVED", "delay 2 : " + delayInformation.getStamp().getTime());
}
Log output:
I/RECVEIVED: delay 1: Mon Jul 31 06:08:58 GMT+02:00 2017
I/RECVEIVED: delay 2: 1501474138319
Good Luck
According to the document:
https://github.com/igniterealtime/Smack/wiki/Smack-4.2-Readme-and-Upgrade-Guide
f you are developing with smack 4.2 on java 7, you need the following dependencies to make it work:
compile "org.igniterealtime.smack:smack-java7:4.2.0"
// Optional for XMPPTCPConnection
compile "org.igniterealtime.smack:smack-tcp:4.2.0"
// Optional for XMPP-IM (RFC 6121) support (Roster, Threaded Chats, …)
compile "org.igniterealtime.smack:smack-im:4.2.0"
// Optional for XMPP extensions support
compile "org.igniterealtime.smack:smack-extensions:4.2.0"

Error while running Flume agent

I m using flume1.4.0 with hbase0.94.10 and hadoop1.1.2....I m new to flume.while i m running an flume agent, i got following error..
Error occurred during initialization of VM The size of the object heap + VM data exceeds the maximum representable size org.apache.flume.node.Application --conf-file=/usr/local/flume/conf/flume.conf --name agent
Exception in thread "main" java.lang.NoClassDefFoundError: occurred
Caused by: java.lang.ClassNotFoundException: occurred
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: occurred. Program will exit.
my agent configuration is as follows:
agent1.sources = tail
agent1.channels = memoryChannel
agent1.sinks = sink1
agent1.sources.tail.type = exec
agent1.sources.tail.command = tail -f /usr/local/jarsfortest/LogsForTest/generatingLogs-app.logs
agent1.sources.tail.channels = memoryChannel
agent1.sinks.sink1.type = org.apache.flume.sink.hbase.HBaseSink
agent1.sinks.sink1.channel = memoryChannel
agent1.sinks.sink1.table = testFlume
agent1.sinks.sink1.columnFamily = log
agent1.sinks.sink1.serializer = org.apache.flume.sink.hbase.RegexHbaseEventSerializer
agent1.sinks.sink1.serializer.regex = [a-zA-Zo-9]*[^C][a-zA-Z0-9]*[^C][a-zA-Z0-9]*
agent1.sinks.sink1.serializer.regexIgnoreCase = true
agent1.sinks.sink1.serializer.colNames = id, no_fill_reason, bid
agent1.sinks.sink1.channel = memoryChannel
agent1.sinks.sink1.type = logger
agent1.channels.memoryChannel.type = memory
agent1.channels.memoryChannel.capacity = 100
Please Help me..
Thanks in advance
This looks like you have a JVM problem rather than a Flume problem. I'd check that the JAR files are not corrupt, that you haven't set max heap size too small, etc.
Whatever is on the end of this truncated message is probably a clue, the size of the object heap + VM data
Update
agent1.channels.memoryChannel.capacity = 100
That capacity looks very small. I'd remove that line and let it use the default.