I can write to db when running in IDE(FB), while after packaging a air, the app wont write to sqlite db, Why? Thanks in advance.
The likely cause is that your installed Air application can't resolve the path to your sqlite file.
What I normally do is to use one of the static public properties of the File class to resolve my sqlite file from eg.
databaseConnection = new SQLConnection();
databaseConnection.addEventListener(SQLEvent.OPEN, onOpen);
databaseConnection.addEventListener(SQLErrorEvent.ERROR, onError);
databaseConnection.openAsync(File.applicationDirectory.resolvePath('mydb.sqlite'));
The key bit here is the File.applicationDirectory.resolvePath('mydb.sqlite') line, in this instance AIR will look for a file called mydb.sqlite in the directory that the application is installed into - in your development environment this would be the same as the bin-debug folder (or whatever folder you are compiling to).
Hope that helps, if not if you can post the code you are using , and what error you are getting I will try and help you further.
The most likely reason is that your DB file resides in the application directory, which is read only.
From Flex 3.5 Language Reference:
File.applicationDirectory—the read-only directory where the application is installed (along with any installed assets)
If this is the case, a possible but not only easy fix would be to just use File.applicationStorageDirectory.
Hope this helps.
N.
Related
I m trying to put a custom path in QML file but can't get it done.
I'm trying to get de db in a shared folder where i'm willing to put the DB so any person who has the program can acces to data.
I'm using Sqlite and Qt Creator 5.7 but not a lot of info about this.
You can simply COPY the database from its default path. Typically that is located (In windows anyways) at
C:\Users\<username>AppData\Local\<program name>\QML\OfflineStorage\Databases
and on Mobile devices it is stored in a similar place --
on android its in a sub folder of:
/data/data/<Program Name>
On *nix it is located:
/home/<user>/.local/share/[ProjectName]/QML/OfflineStorage/Databases
I have not developed anything for IOS in a long time so please bear with me. Using the Swift language for the first time in XCode 6.3.
I have a pre-existing sqlite database, myDB.sqlite, that I want to import into my project.
I have added the sqlite Framework, added FMDB and the bridging header file and then added the myDB.sqlite file to my project. It is also included in "Copy Bundle Resources".
I am just trying to access myDB.sqlite in my bundle directory to copy it to my Documents directory when the app is run for the first time in the Simulator. However it keeps saying it cannot find the file.
In my AppDelegate.swift:
let dbPath = NSBundle.mainBundle().pathForResource("myDB", ofType:"sqlite")
It keeps telling me that dbPath is nil.
Check the target membership of your SQLite database and it's done:
I recently take over a web application project using websphere and log4j running under AIX. To create a development environment, I setup all the components in windows, using eclipse to compile a WAR file and deploy it.
All is working fine except that log file is not created.
I changed the log file in log4j.properties from something like in below and and give everyone full access permission to the directory:
log4j.appender.F1.File=/abc/def/logs/admin.log
to
log4j.appender.F1.File=c:/logs/admin.log
What else can I check?
I create a simple standalone testapp which use the same log4j.properties and it can create the log file, but when the servlet deployed to websphere, it doesn't work. Please help! Thanks!
Ok, I think this article should help you. It seems that WebSphere CE uses log4j by default and controls it with a global properties file. There is a section on how to use application-specific properties files.
Here is what I try and do to troubleshoot similar issues.
Turn on log4j debugging to see where it actually picks up the file from. You need evidence of which file is picked up (so turning the debug on is a worthwhile activity) This provides you information with what log4j is trying to do to locate the configuration file.
-Dlog4j.debug=true
I would not hardcode the log4j location in the code. Instead I
would use the log4j.configuration System property and state that in
the JVM arguments. This way even I don't need to touch my code.
-Dlog4j.configuration=file:///home/manglu/log4j.properties
I would use this approach irrespective of the runtime server that I use (be it Tomcat or WAS CE or WAS)
Hope this helps
I suggest you use environment variables set on your server like this :
You must access the admin console of your server.
Under custom properties
Server_path=/abc/def/logs
In your log4j, use this : {$server_path}/log.txt
Make sure the user running the app has access to that directory.
I have a solution contains a web project named "Web", and a dependeny class library project named "Service". I use the ASP.Net MVC2 to build up my solution. As you know, there's a Content folder storing images and css files under the web project. Now I need to get the stream reference of "Content\Images\anon.png" in one class of my "Service" project.
I tried
var result = new FileStream(#"Content\Images\anon.png", FileMode.Open);
and press F5 to debug, but it cannot find the file and throws an exception.
I am using VS2010, please tell me how can I access to this image. Thanks very much.
Can you try
Server.MapPath("~/Content/Images/anon.png")
You can use System.Web.VirtualPathUtility.ToAbsolute("~/Content/Images/anon.png"); or RequestContext.HttpContext.Request.MapPath as well
Visual studio makes it to a temp directory for your web app, not your solution folder/ If you publish your app on a IIS server, the Server.map will be correct.
Because it is searching for the file in Debug\Content\Images\ . Are you sure the images is really there? Make sure that your file is in that path.
I'm writing a desktop app which needs a simple persistence layer - I found out about SubSonic and it's capability to work with SQLite. However I need to keep the database file in user's AppData folder and don't know how to put such value into app.config - I don't want to use absolute paths.
Can app.config somehow access enviroment variables or reference application data folder?
For subsonic v2.x I would ignore the app.config connection string and just set it at runtime before working with the database. The provider name stays the same of course.
string dbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), #"MyApplication\Northwind.db3");
DataService.Providers["Northwind"].DefaultConnectionString =
String.Format(#"Data Source={0};Version=3;New=False;Connection Timeout=3", dbPath);
There's no way to specify the AppData folder in the app.config for a connections string.
But what you could do is write the value to the config file either during install or when the application is first run.
The "framework way" of finding appdata is to use Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
This will find the correct appdata path regardless of platform.
There are several ways if you are using ASP.NET , in either language
Server.MapPath("~") will return the root of the application as a full path name then you can just add "/app_data" to it to get you're full path.
Alternatively inspect the HttpContext.Current.Request and HttpContext.Current.Application
there are numerous ( and much better then the one I just mentioned ) properties that will provide you with the same folder - being the root of the application as s full path.
Note that these should all work even if you have the application as a virtual folder and a regular folder with an application configures in IIS on that folder
However this is only possible at runtime , so it can't really be mentioned in the app.config. you could try using relaltive paths from where the app.config is resident IE "../App_Data" or "/App_data" but I'm not sure of you're exact requirements.
Good luck