Jump to content

Storage using java db, yaml, or xml?


hkiller1

Recommended Posts

I'm trying to make a money mod and I need to be able to store the variable in a file. Whats the best / easiest thing to use to do this, java db, yaml, or xml? Also I cant figure out how to use any of them to save and load data so any tutorials will be very helpful.

Link to comment
Share on other sites

I think im going to try java db, im trying to use http://docs.oracle.com/javadb/10.8.2.2/getstart/index.html , so far I have

package economy.common;

import java.sql.*;

public class Data {

public static void init() throws SQLException{

    String sqlCreate = "CREATE TABLE IF NOT EXISTS Economy"
            + "  (player           VARCHAR(20),"
            + "   amount            INTEGER)";

	try {
		Connection db = DriverManager.getConnection("jdbc:derby:Economy;create=true");
		db.createStatement().execute(sqlCreate);
		System.out.println("Economy successfully connected to the database");
		} 
	catch (Throwable e) {	
		System.out.println("Economy failed to connected to the database");
		}

}

public void load() throws SQLException {
	Connection db = DriverManager.getConnection("jdbc:derby:economy;create=true");



	db.close();
}


public void save(String player, String amount) throws SQLException {
	Connection db = DriverManager.getConnection("jdbc:derby:economy;create=true");



	db.close();
}

}

 

but it wont start and connect to the database. Why is it not starting it?

Link to comment
Share on other sites

Why use a db? For minecraft servers that is more than you need, you just need packet handling and a local map. I recommended using minecraft's built in compressor for saving and loading. maps can be saved directly to the disk and reloaded:

http://www.minecraftforge.net/forum/index.php/topic,3211.msg21401.html#msg21401

 

That is the easiest option because after the save and load, you just use the map normally. Forge offers an event on the event bus so you can save when the world saves.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.