Uncaught Error: no such table: test (code 1): - titanium

I'm using titanium and testing against an android emulator - but any advice relevant to iOs is also welcome! i am trying to use titanium with a database. I'm using the firefox sql lite plugin to make my db - so i make it, and then i go
var databasewindow=Ti.UI.createWindow({
width:Ti.UI.SIZE,
height:Ti.UI.SIZE,
backgroundColor:"#bb7711",
color:"#fff",
font: { fontSize:48 },
fontFamily:'BurnstownDam-Regular',
layout: 'vertical'
});
var db=Titanium.Database.install('test.sqlite','test');
db.close();
var db = Ti.Database.open('test');
//db.execute('INSERT INTO test(name,age) VALUES('Humayoon','25')');
db.execute('INSERT INTO test(name) VALUES ("Humayoon")');
//db.execute('INSERT INTO test("name","age") VALUES ("'+'Zohaib'+'","'+'23'+'")');
var sql=db.execute('SELECT * FROM test');
while (sql.isValidRow())
{
//var cityId = sql.fieldByName('id');
var Name = sql.fieldByName('name');
//var cityContinent = sql.fieldByName('age');
Ti.API.info(Name);
sql.next();
}
sql.close();
db.close();
databasewindow.open();
error here
[ERROR] : TiExceptionHandler: (main) [134,134] ----- Titanium
Javascript Runtime Error ----- [ERROR] : TiExceptionHandler: (main)
[0,134] - In app.js:15,4 [ERROR] : TiExceptionHandler: (main)
[1,135] - Message: Uncaught Error: no such table: test (code 1): ,
while compiling: INSERT INTO test(name) VALUES ("Humayoon") [ERROR] :
TiExceptionHandler: (main) [0,135] - Source: db.execute('INSERT INTO
test(name) VALUES ("Humayoon")'); [ERROR] : V8Exception: Exception
occurred at app.js:15: Uncaught Error: no such table: test (code 1):
, while compiling: INSERT INTO test(name) VALUES ("Humayoon") [ERROR]
: File: fail readDirectory() errno=2

Related

how to load .jar dynamically to apk using frida

I'm going to load .jar dynamically to apk and call a certain method of a class in that jar. Using frida, I've tried to load jar file but failed.
Java.perform(function(){
var pathclassloader= Java.use('dalvik.system.PathClassLoader');
var myClassLoader = pathclassloader.$new("/Sdcard/testjar.jar", classloader.getSystemClassLoader());
const Class=Java.use('java.lang.Class');
var forName = Class.forName.overload('java.lang.String', 'boolean', 'java.lang.ClassLoader');
forName.call('client', true, myClassLoader);
})
it failed with error :
{'type': 'error', 'description': "ReferenceError: identifier 'classloader' undefined", 'stack': "ReferenceError: identifier 'classloader' undefined\n at [anon] (../../../frida-gum/bindings/gumjs/duktape.c:81019)\n at /script1.js:6\n at frida/node_modules/frida-java-bridge/lib/vm.js:11\n at E (frida/node_modules/frida-java-bridge/index.js:346)\n at frida/node_modules/frida-java-bridge/index.js:298\n at frida/node_modules/frida-java-bridge/lib/vm.js:11\n at frida/node_modules/frida-java-bridge/index.js:278\n at /script1.js:15", 'fileName': '/script1.js', 'lineNumber': 6, 'columnNumber': 1}
Any help for me. Thanks.

karate- run time error in evaluation of 'karate-config.js' [duplicate]

I'm trying use karate for e2e tests and have started with a minimal setup. I want to create some config items in karate-config.js for use in the tests but karate is reporting that file is not a js function and hence the test fails trying to get the config:
Warning: Nashorn engine is planned to be removed from a future JDK release
12:16:35.264 [Test worker] WARN com.intuit.karate - not a js function or feature file: read('classpath:karate-config.js') - [type: NULL, value: null]
---------------------------------------------------------
feature: classpath:karate/insurer.feature
scenarios: 1 | passed: 0 | failed: 1 | time: 0.0163
---------------------------------------------------------
HTML report: (paste into browser to view) | Karate version: 0.9.1
file:/Users/srowatt/dev/repos/api/price-service/build/surefire-reports/karate.insurer.html
---------------------------------------------------------
-unknown-:4 - javascript evaluation failed: priceBaseUrl, ReferenceError: "priceBaseUrl" is not defined in <eval> at line number 1
org.opentest4j.AssertionFailedError: -unknown-:4 - javascript evaluation failed: priceBaseUrl, ReferenceError: "priceBaseUrl" is not defined in <eval> at line number 1
This is my karate-config.js:
function fn() {
return {
priceBaseUrl: "http://localhost:8080"
};
}
This is my insurer.feature test:
Feature: which creates insurers
Background:
* url priceBaseUrl
* configure logPrettyRequest = true
* configure logPrettyResponse = true
Scenario: basic roundtrip
# create a new insurer
Given path 'insurers'
And request { name: 'Sammy Insurance', companyCode: '99' }
When method post
Then status 201
And match response == { resourceId: '#number', version: 0, createdBy: 'anonymousUser' }
* def insurerId = response.resourceId
# get insurer by resource id
Given path 'insurers', insurerId
When method get
Then status 200
And match response == { id: '#(id)', name: 'Sammy Insurance', companyCode: '99' }
This is the InsurerTest.java test runner:
package karate;
import com.intuit.karate.junit5.Karate;
class InsurerTest {
#Karate.Test
public Karate testInsurer() {
return new Karate().feature("classpath:karate/insurer.feature");
}
}
Please use below code in the karate-config.js
function() {
return priceBaseUrl='http://localhost:8080';
}
When I see this:
Warning: Nashorn engine is planned to be removed from a future JDK release
I suspect you are on Java 9 or 11 ? To be honest, we haven't fully tested Karate on those versions of Java yet. Would it be possible for you to confirm that Java 8 (maybe 9 / 10 also) is OK.
That said, we are interested in resolving this as soon as possible, so if you can submit a sample project where we can replicate this, please do so: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue
EDIT: Karate 1.0 will use GraalVM instead of Nashorn and will run on even JDK 16: https://software-that-matters.com/2021/01/27/7-new-features-in-karate-test-automation-version-1_0/

How To Retrieve Data From Rest API In Appcelerator

I have the misfortune of further developing an existing mobile application in Appcelerator. The app uses a Rest API on a remote server to read and write data. The API works well in test environments and in production. I need to post data to the API and read the output. Here is an example of what the output of the API looks like after a POST command:
{
"equipment":
{
"result": "create",
"id": 419213
},
"_meta":
{
"offset": 0,
"limit": -1,
"total_results": 1,
"url": "http://localhost:8080/api/v1/equipment",
"utc_start_time": 1459449461115,
"nano_total_time": 74771
}
}
I am able to successfully post the data in Appcelerator. I have verified this in the database that the CRUD operation is acting on. However, I am unable to get the aforementioned data from the httpClient object that makes the call, despite following the directions in the outdated Titanium documentation.
Here is my Appcelerator code:
var payload = "name=atad&asset_number=adtasd&department_id=185080&property_id=10086&designator_id=379828&is_leased=N&is_assignable_asset=N&status=A";
var url = "http://localhost:8080/api/v1/equipment";
var client = Ti.Network.createHTTPClient({
onload : function(e) {
Ti.API.info(e); // {}
Ti.API.info(e.source); // []
Ti.API.info(JSON.stringify(e.source)); // {}
Ti.API.info(JSON.stringify(e.source.reponseText)); // null
Ti.API.info(JSON.stringify(e.source.reponseData)); // null
Ti.API.info(this); // []
console.log(JSON.stringify(this)); // {}
Ti.API.info(JSON.stringify(this.reponseText)); // null
Ti.API.info(this.reponseData); // null
}
,onerror : function(e){
Ti.API.info(e);
alert("error");
}
});
var auth = 'Basic ' + Ti.App.Properties.getString('auth');
client.open("POST", apiUrl);
client.setRequestHeader('Authorization', auth);
client.setRequestHeader('Content-Type', 'text/plain');
client.send(payload);
Here is the console output:
[INFO] : {
[INFO] : code = 0;
[INFO] : source = "[object TiNetworkHTTPClient]";
[INFO] : success = 1;
[INFO] : type = load;
[INFO] : }
[INFO] : [object TiNetworkHTTPClient]
[INFO] : {"method":"POST","url":"http://localhost:8080/api/v1/equipment"}
[INFO] : <null>
[INFO] : <null>
[INFO] : [object TiNetworkHTTPClient]
[INFO] : {"method":"POST","url":"http://localhost:8080/api/v1/equipment"}
[INFO] : <null>
[INFO] : <null>
The documentation here http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Network.HTTPClient explicitly says to use this.responseText, but that is clearly not giving me the results I need. I need that "id" that is being returned from the server.
How do I read the data that is returned from the server after a post API call?
There is just a typo in this.responseText
Have a look at this module: https://github.com/jasonkneen/RESTe
It makes your life easier and gives you a great way to the same syntax for future projects!
If you want to keep your syntax (which is fine too):
have a look at this example: https://github.com/m1ga/titanium-libraries/blob/master/api.js#L49
and the following lines. It shows you how to read the JSON. Basically you have to wait for if (this.readyState === 4) {} inside the onload and then read the this.responseText or JSON.parse() it.
It looks like the apiUrl variable is not defined?
Which could explain a lot or your current frustration.

Cannot get play-mailer gives cannot find symbol

When trying to use the player-mailer plugin I get the following error while compiling:
[error] /Users/Luuk/Documents/Java/Y2kBooking/app/logic/support/Mails.java:4: package play.libs.mailer does not exist
[error] play.libs.mailer.Email
[error] /Users/Luuk/Documents/Java/Y2kBooking/app/logic/support/Mails.java:5: package play.libs.mailer does not exist
[error] play.libs.mailer.MailerClient
[error] /Users/Luuk/Documents/Java/Y2kBooking/app/logic/support/Mails.java:14: cannot find symbol
[error] symbol: class MailerClient
[error] location: class logic.support.Mails
[error] MailerClient
app/logic/support/Mails.java:24: cannot find symbol
[error] symbol: class Email
[error] location: class logic.support.Mails
This is my mailer:
package logic.support;
import play.Configuration;
import play.libs.mailer.Email;
import play.libs.mailer.MailerClient;
import javax.inject.Inject;
public class Mails {
#Inject
MailerClient mailerClient;
public void sendLoggerEmail(String message, Exception e) {
String fullMessage = "The following error occured:\n" + message;
if (e != null) {
fullMessage += "\n\n" + "Error message:\n" + e.getMessage() + "\n\nStacktrace\n" + org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace(e);
}
Email email = new Email();
email.setSubject("Booking application warning");
email.setFrom("Booking system FROM <" + Configuration.root().getString("adminEmail") + ">");
email.addTo("Webmaster TO <" + Configuration.root().getString("adminEmail") + ">");
email.setBodyText(fullMessage);
mailerClient.send(email);
}
}
In build.sbt:
libraryDependencies ++= Seq( javaJdbc , cache , javaWs , evolutions , "mysql" % "mysql-connector-java" % "5.1.18", "org.mockito" % "mockito-core" % "1.10.19" % "test", "com.typesafe.play" %% "play-mailer" % "3.0.1")
I did clean the project and rebuild, but always the same. I am using Play (Java) 2.4.4
[Edit:]
The jar is present, and IDEA has no problem with it, so it seems that it is just not available at runtime.
[Edit2:]
The problem seems only when Debugging with IDEA. Running from the terminal with activator works fine.
I discovered that it was a problem with the debugging session of IDEA.
Restarting everything solved the problem.

PDI plugin, getInputRowMeta() throw Non pointer exception

In my plugin, I try to get MetaData info from previous step, so that I can do some work on the row data based on it's MetaData info( column name).
It works fine as per the data, since r = getRow(), can get the data. but when calling getInputRowMeta() to get previous step's row meta, it throws Non pointer exception.
Code example as follow( mainly the processRow() function.)
public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException {
meta = (NAAClientStepMeta) smi;
data = (NAAClientStepData) sdi;
option = meta.getOption();
message = option;
if (first) {
first = false;
if(option.equals("Publisher AccountIDs")){
getInputRowMeta().size(); // don't work here, throw exception.
RowMetaInterface rm = (RowMetaInterface) getInputRowMeta().clone();
data.outputRowMeta = rm;
meta.getFields(rm, getStepname(), null, null, this);
//String previousSteps[] = transMeta.getPrevStepNames("New Acquisio API Client");
//RowSet rowSet = this.findOutputRowSet(transMe);
//RowMetaInterface rowMeta = rowSet.getRowMeta();
r = getRow();
when calling getInputRowMeta(), it throws Exception as follows:
2015/08/05 14:11:00 - New Acquisio API Client 2.0 - ERROR (version 4.4.0 stable, build 17588 from 2012-11-21 16.02.21 by buildguy) : Unexpected error
2015/08/05 14:11:00 - New Acquisio API Client 2.0 - ERROR (version 4.4.0-stable, build 17588 from 2012-11-21 16.02.21 by buildguy) : java.lang.NullPointerException
2015/08/05 14:11:00 - New Acquisio API Client 2.0 - ERROR (version 4.4.0-stable, build 17588 from 2012-11-21 16.02.21 by buildguy) : at com.acquisio.kettle.plugins.NAAClientStep.processRow(NAAClientStep.java:183)
2015/08/05 14:11:00 - New Acquisio API Client 2.0 - ERROR (version 4.4.0-stable, build 17588 from 2012-11-21 16.02.21 by buildguy) : at org.pentaho.di.trans.step.RunThread.run(RunThread.java:50)
2015/08/05 14:11:00 - New Acquisio API Client 2.0 - ERROR (version 4.4.0-stable, build 17588 from 2012-11-21 16.02.21 by buildguy) : at java.lang.Thread.run(Thread.java:745)
Are there any place StepMeta class, StepData class I should set?
Thats absolutely right. The underlying PDI class doesn't know about the metadata of the incoming stream UNTIL it has read the first row. So your r=getRow() has to come earlier. A common occurance when building UDJC steps!