Not able to get populated sqlite db from the android emulator - react-native

Using react-native-sqlite-storage for the first time, I was able to create an sqlite db file in the Android emulator, created a table in it and inserted a row successfully. After that on a button click, I also verified by a select that the row was inserted.
Then I used Android Studio's "device file explorer" to locate the test.db file in the data\data<apppkg>\databases folder and used "save as" to copy it to the PC's folder. Now when I open the test.db file in the browser utility, it's empty! There is no table in it.
Suspecting a "flush" problem, I also tried a db.close() in the app. But still I'm not able to get the populated database copy from the Android emulator. What am I doing wrong?
Update: I noticed that on the android emulator, there are 2 more files with the database file--an shm and a wal file. Reading some other threads, it seems they are keeping the journal so it seems the data is not committed yet. Those threads mention closing the cursor. But there is no such mention in the storage library docs. How do I ensure a cursor close from the App other than calling the close() that does not really close it and commit the data.

Finally, for my simple, single table requirement, I ended up calling executeSql on the db object instead of doing it through a transaction. That solved the problem and on close, it's always a single file. Somehow, when you use a transaction, the other files linger around even if you close the db.

Related

I see deleted records in Spring with JDBC

I have a webapp with Spring. I connect to the DB via JDBC. My issue comes in the following workflow:
I insert some testing record to the DB with the app. I see in the app and in SQLDeveloper (same query) that the record gets inserted. No problem.
I delete that record from SQLDeveloper. I see in SQLDeveloper that the record gets deleted. No problem
I go back to the webapp and refresh the page. Problem: the deleted records are still there!.
I'm sure I'm using the same query in the app and in SQLDeveloper (this is the only instance when I don't see the same in both environments). I tried restarting the app, but I can't imagine what else to do. Is there any cache system in Spring that could be causing this?
I can post some code if it would be any help, though I doubt it...
I suspect that you haven't committed the result of your deletion in SQLDeveloper, so you see your deletion in SQLDeveloper (same transaction), but not anywhere else, because those are running in different transactions.
EDIT: To commit, you can just execute the command commit; in SQLDeveloper, or hit the commit button at the top of the query window (a DB icon with a green tick in front of it)

SQL Server - insufficient memory (mscorlib) / 'the operation could not be completed'

I have been working on building a new database. I began by building the structure within the database it is replacing and populating this as I created each set of tables. Once I had made additions I would drop what had been created and execute the code to build the structure again and a separate file to insert the data. I repeated this until the structure and content was complete to ensure each stage was as I intended.
The insert file is approximately 30mb with 500,000 lines of code (I appreciate this is not the best way to do this but for various reasons I cannot use alternative options). The final insert completed and took approximately 30 minutes.
A new database was created for me, the structure executed successfully but the data would not insert. I received the first error message shown below. I have looked into this and it appears I need to use the sqlcmd utility to get around this, although I find it odd as it worked in the other database which is on the same sever and has the same autogrow settings.
However, when I attempted to save the file after this error I received the second error message seen below. When I selected OK it took me to my file directory as it would if I selected Save As, I tried saving in a variety of places but received the same error.
I attempted to copy the code into notepad to save my changes but the code would not copy to the clipboard. I accepted I would lose my changes and rebooted my system. If I reopen this file and attempt to save it I receive the second error message again.
Does anyone have an explanation for this behaviour?
Hm. This looks more like an issue with SSMS and not the SQL Server DB/engine.
If you've been doing few times, possibly Management Studio ran out of RAM?
Have you tried breaking INSERT into batches/smaller files?

Why can't i manually update my access database? (once it is connected to vb.net)

So I have created a project in Vb.net, and have been retrieving, inserting, and updating data from an access database using it. I have realised that I must change some of the records within the database and went about doing so in access (having opened the database within the debug folder). So I would update the records, and then save, before closing it. Whenever I reopened it again, it had reverted to the older version. When trying to overwrite, it corrupted some of the records and sometimes the whole database, saying "Id" is not valid. Is there an error in my logic? Do I have to make a new database connection?
You're making changes to the wrong database. The original is, or at least it should be, in the project folder. When you build, that original is copied to the output folder. That way, any changes you make while debugging do not pollute the original, so it's clean when it comes time for you to release your application.

ssms error while saving .sql file... " The operation cannot be completed"

I am using sql server management studio 2008. I have a .sql file of about 45 MB. When I make some change in this and try to save using Save Button or press Ctrl+S.... error occurs as:
The operation cannot be completed
But when I installed SSMS, it was working properly, but after that 45 mb file operation it's not working properly. Also Object Explorer is not visible, even after selecting from menu>>view>>object explorer. I am using Windows 7 32 bit.
I've had variations of this problem, where I can't save the file, especially when I've used the undo capability a lot, and most frequently when I've modified a script from a different development tool, while it was open in Management Studio.
Have you tried: save as to another filename?
(If you're concerned about losing the undo capability, you might try save as to a different filename, then do a bunch of undo commands and save as again to another filename... etc... until you think you've kept as many versions/steps of the undo process as you want. Rem: a shortcut for undo is <ctrl>-Z, and for redo is <ctrl>-Y... [and you can just hold down <ctrl>-Z or <ctrl>-Y :) ], but if you type or change anything after undo, you lose the ability to redo.)
If you can't save as either, then copy/paste the code into another application (such as Notepad, or Notepad++), and SAVE IT FROM THAT APPLICATION. (Again, if you want to simulate your undo stack, do this again after some undo commands, etc.)
But the bottom line is, I've found I have to at least CLOSE THE FILE, and reopen it, to get past these problems... sometimes exit Mgmt Studio... and then, as a bunch of old jokes about Microsoft Support go...
You might have to restart your computer.
(P.S. I agree with Tom -- you might want to split this script into smaller scripts.)

SQLite database image getting malformed at build time in Xcode

I'm working on a iOS 6 app, and am using a SQLite database to store data. At startup the app does a select on the database and displays the results on the first screen.
However I've started to get an "Database disk image is malformed" error when trying to run the select.
The strange thing is that I can use SQLite browser, http://sqlitebrowser.sourceforge.net/, to do the select on the database in the project folder. But if I try to open the database after it has been copied to the simulator folder, /Users//Library/ApplicationSupport/iPhone simulator/6.0/Applications/... then I get a disk image is malformed.
The database is not being accessed by a background thread, nor am I using breakpoints to halt execution as is being suggested as a reason here sqlite database disk image malformed on iPhone SDK.
No more than one execution being done on the database at once.
All hints, tips and possible solutions are appreciated.
I've found out that this had something to do with me bundling a rather large database file with the app (larger than 3 GB). I've fixed the problem by doing a in-app download of the data over wifi. This caused the database error to fade away.