Skip to content
This repository has been archived by the owner on Dec 4, 2022. It is now read-only.

Can't download database #10

Open
donfour opened this issue Nov 19, 2017 · 3 comments
Open

Can't download database #10

donfour opened this issue Nov 19, 2017 · 3 comments

Comments

@donfour
Copy link

donfour commented Nov 19, 2017

Hi! I was following the quick start guide to setup the api.
First of all, according to the javadoc, getRemainingArrivalTimeText method doesn't exist anymore. Also, I ran into the following error when I ran my code:

ArrivalManager: Database is not loaded. Loading now...
ArrivalManager: It might take a while...
java.io.IOException: Server returned HTTP response code: 403 for URL: https://db.kmbeta.ml/kmbeta_db.json
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1876)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474)
	at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
	at com.github.mob41.kmbeta.api.BusDatabase.loadWebDB(BusDatabase.java:173)
	at com.github.mob41.kmbeta.api.ArrivalManager.<init>(ArrivalManager.java:163)
	at com.github.mob41.kmbeta.api.ArrivalManager.<init>(ArrivalManager.java:72)
	at test.Test.main(Test.java:17)
ArrivalManager: Could not load database. Check your internet connection or the database file placed near your application.
Exception in thread "main" com.github.mob41.kmbeta.exception.CouldNotLoadDatabaseException: Could not load database. Check your internet connection or the database file placed near your application.
	at com.github.mob41.kmbeta.api.ArrivalManager.<init>(ArrivalManager.java:186)
	at com.github.mob41.kmbeta.api.ArrivalManager.<init>(ArrivalManager.java:72)
	at test.Test.main(Test.java:17)

However, I am able to open https://db.kmbeta.ml/kmbeta_db.json in my Chrome browser, so this shouldn't be the server's problem.
Do you have any idea why this would occur? Thank you!

@donfour
Copy link
Author

donfour commented Nov 19, 2017

Also, there isn't clear instructions of how to set up an offline database? e.g. where should I put the downloaded .json file? Thanks!

@a1aw
Copy link
Owner

a1aw commented Nov 25, 2017

I am still investigating about this error. The downloaded .json file should be placed next to the application .jar/.exe file. If testing your project in eclipse IDE or something, put the database in your project folder.

@a1aw
Copy link
Owner

a1aw commented Nov 25, 2017

By using the child method BusDatabase.loadDatabase(Object classParent, boolean loadFromClassResources) you can load file from the file-system (near the application) or from the class resources.

For example:
To load a database file near the application: BusDatabase.loadDatabase(false);

To load a database file in the class resources: BusDatabase.loadDatabase(YourClass.class, true);

or

BusDatabase.loadDatabase(true);

This method will use BusDatabase.class as root class

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants