Skip to main content

Posts

Showing posts with the label database

database insertion working well on android emulator but not on device

I have created a database using this tutorial . When I insert the values in my table, it works on the emulator and I have seen the values are inserted correctly. But when I run my application on a device, it gives me this error: 02-29 17:30:45.341: E/Database(3300):android.database.sqlite.SQLiteException:no such table: recently_used: , while compiling: INSERT INTO recently_used(iconsset_name, icon_name) VALUES(?, ?); 02-29 17:30:45.341: E/Database(3300): at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method) 02-29 17:30:45.341: E/Database(3300):at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:92) 02-29 17:30:45.341: E/Database(3300):at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:65) 02-29 17:30:45.341: E/Database(3300): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:83) 02-29 17:30:45.341: E/Database(3300): at android.database.sqlite.SQLiteStatement.<init> (S

Android database closed exception

I'm working on a project where I'm downloading and saving data from web to sqlite database. A few minutes ago I receive a strange exception to our server from a user which is saying that the sqlite database is already closed..and I just checked the whole file where the exception happened and I'm not calling dbHelper.close(); . Here is the function where the app crashes and LogCat message : public void insertCollectionCountries(JSONObject obj, Context context) { //Insert in collection_countries if(RPCCommunicator.isServiceRunning){ Log.w("","JsonCollection - insertCollectionCountries"); ContentValues valuesCountries = new ContentValues(); try { collectionId = Integer.parseInt(obj.getString("collection_id")); dbHelper.deleteSQL("collection_countries", "collection_id=?", new String[] {Integer.toString(collectionId)}); JSONArray arrayCountries = obj.getJSONArray("

ResultSet How to get strin from object when data is null?

In my Oracle table there are columns with different type. I want to read all columns as number. String str = resultSet.getString("col1"); The problem is that if column in database is defined as number, and value is 0.5 The returned string will be .5 I can not use any other getter like getDecimal and etc. if I use: String str = resultSet.getObject("col1").toString(); I'll get an exception if the value is null.

Very slow query where table have many records

I' m using sqlite on iphone. I have table with 200 000 records. It' s size is small, only 2 MB. I' m doing standard select(3 collumns) with two simple condtions. I' m operating only on integer values( in return and condtion). All data are unique. I'm get usually only 10-50 records from database. In spite of that my query take 3 sec. It' s a lot of time. How i can improve this ? Edit: I can't load my table with other thread. NSString * query = [ NSString stringWithFormat:@"SELECT rRozklad.hour, rRozklad.minute, rRozklad.marks FROM rRozklad.idOkres=%i AND rRozklad.idPolaczeniaLinie=2 ORDER by rRozklad.hour, rRozklad.minute", okres]; NSLog(@"%@", query); const char * querystring = [ query UTF8String ]; sqlite3_stmt * statment; if(sqlite3_prepare_v2(database, querystring, -1, &statment, nil) == SQLITE_OK){ while(sqlite3_step(statment) == SQLITE_ROW){ NSMutableArray * temp = [[NSMutableArray alloc] initWithCapacity:2];

browser keeps on looking for the data but never fetches it

Following is a snippet that is meant to fetch the data from the database. But when i click the submit button to see the data, the browser keeps on looking for the data but never displays anything (the browser doesn't show the next page but keeps on looking on the same page) . I don't know what the problem is. Snippet that fetches the data : public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException { try { Context context = new InitialContext(); DataSource dataSource = (DataSource)context.lookup("java:comp/env/jdbc/MyDatasource"); Connection connection = dataSource.getConnection(); String sqlStatement = "SELECT * FROM INFORMATION"; PreparedStatement statement = connection.prepareStatement(sqlStatement); ResultSet set = statement.executeQuery(); PrintWriter writer = response.getWriter(); response.setContentType("text/plain");

Is it possible to show screen only once when app starts up?

I want to be able to prompt the users to enter the details required for the app only when it starts up for the first time (not other times). These details will be held in a database on the phone. Would it be better to check the database each time or put these details in a shared preference? Furthermore, is this type of activity even possible on Android?

Registration blanket, database, info, wordpress, mySQL, e-mail

I'm making websites for a company where users have to "register" with names and a lot of different information to attend the event. (It's a video-event - info would be name, e-mail etc.) I now got a Wordpress webpage, at the blanket doesn't necessary need to be on the site, but can open in a separate window. I need to, somehow make it easy for admin to look at the users who registered, send them e-mails etc. Make a list of everyone who register, for the admin to see. How would be the easiest way to do this? I know how to make a form, and pull the information into the database.. Any good ideas, plugins or examples?? Thanks

Distinguish new vs existing exceptions

I am creating a PHP application and I want to display the number of times an error has occurred. The problem that I am trying to figure out is if an error has already been reported or if its new using the following values: Message (ie: Attempted to divide by zero.) Stack trace (ie: at componentNETapp.Form1.btnTrackExceptionsUn_Click(Object sender, EventArgs e) ...) Source (ie: componentNETapp) Target site (ie: Void btnTrackExceptionsUn_Click(System.Object, System.EventArgs)) Thanks

Apostrophe issue when inserting into MySQL

I have a script where I submit some fields that get entered into a MySQL database when I submit it now it goes through successfully but never gets inserted into the database if one of the fields has an apostrophe. What can I modify to get this to work? if ($_POST) { $name = trim($_POST['your_name']); $email = trim($_POST['your_email']); $answers = $_POST['answers']; $i = 0; foreach ($answers as $a) { if (trim($a)) $i++; } if ($name && $email && $i >= 40) { $array = array(); $q = mysql_query("select * from fields"); while($f = mysql_fetch_array($q)) $array[$f['label']] = $answers[$f['ID']]; $array = serialize($array); $time = time(); $ip = $_SERVER['REMOTE_ADDR']; $token = md5($time); $result = mysql_query("insert into data (submit_name, submit_email, submit_data, submit_confirm, submit_time, submit_ip, submit_token) values ('$name', 

Doctrine 1.2 / Zend

Im having trouble with doctrine generating the code for a query that has a umlaut in. $q = Doctrine_Query::create() ->select('DISTINCT p.project_name, fqha.form_question_has_answer_request, fqha.form_question_has_answer_form_id, fqha.form_question_has_answer_user_id, u.user_username, c.company_hall_no, c.company_type, c.company_company_name, c.company_country, c.company_stand_number, c.company_image_file_1, pchu.project_company_has_user_project_id, pchu.project_company_has_user_user_id') ->from('Klarents_Model_ProjectCompanyHasUser pchu') ->innerJoin('pchu.Klarents_Model_Company c') ->innerJoin('pchu.Klarents_Model_Project p') ->innerJoin('pchu.Klarents_Model_User u') ->innerJoin('pchu.Klarents_Model_Form f') ->leftJoin('pchu.Klarents_Model_FormQuestionHasAnswer fqha ON fqha.form_question_has_answer_form_id = ' . $this->zon