Thread: [SQL] Item CFG

Results 1 to 3 of 3
  1. #1 [SQL] Item CFG 
    Registered Member
    Join Date
    Mar 2010
    Posts
    121
    Thanks given
    12
    Thanks received
    9
    Rep Power
    24
    I just finished importing the Item.CFG file into my SQL database, thought I would share the SQL file and query for people looking to use SQL type loading.

    You can download it here.


    Code:
    	public boolean loadItemList() {
    		if(!SQLEngine.Online) {System.out.println("SQL Engine is not online. Item Spawns failed."); return false;}
    		String Query = "SELECT * FROM items";
    		try {
    		Statement S = World.createStatement();
    		ResultSet R = S.executeQuery(Query);
    		int[] Bonuses = new int[12];
    		int ID = 0;
    		String IName;
    		String IDes;
    		int ShopVal;
    		int LowAlch;
    		int HighAlch;
    		while (R.next()) {
    			ID = R.getInt("ItemID");
    			IName = R.getString("ItemName");
    			IDes = R.getString("Description");
    			ShopVal = R.getInt("ShopValue");
    			LowAlch = R.getInt("LowAlch");
    			HighAlch = R.getInt("HighAlch");
    			Bonuses[0] = R.getInt("AttackStab");
    			Bonuses[1] = R.getInt("AttackSlash");
    			Bonuses[2] = R.getInt("AttackCrush");
    			Bonuses[3] = R.getInt("AttackMagic");
    			Bonuses[4] = R.getInt("AttackRange");
    			Bonuses[5] = R.getInt("DefenceStab");
    			Bonuses[6] = R.getInt("DefenceSlash");
    			Bonuses[7] = R.getInt("DefenceCrush");
    			Bonuses[8] = R.getInt("DefenceMagic");
    			Bonuses[9] = R.getInt("DefenceRange");
    			Bonuses[10] = R.getInt("StrengthBonus");
    			Bonuses[11] = R.getInt("PrayerBonus");
    /*This is where you put the Item into the JVM, my method here may not work for your source.*/
    newItemList(ID,IName,IDes,ShopVal,LowAlch,HighAlch,Bonuses);			
    		}
    		System.out.println("Item Data Loaded from Database.");
    		return true;
    		
    		} catch (Exception E) {
    			System.out.println("Error Loading Item Data: "+E);
    			return false;
    		}
    	}
    Enjoy.
    Reply With Quote  
     

  2. Thankful user:


  3. #2  
    Registered Member
    Mister Maggot's Avatar
    Join Date
    Dec 2008
    Posts
    7,227
    Thanks given
    3,283
    Thanks received
    2,875
    Rep Power
    5000
    You wrote a really shitty select query.

    Use prepared statements and don't use terms you don't fucking know...

    /*This is where you put the Item into the JVM, my method here may not work for your source.*/
    Reply With Quote  
     

  4. #3  
    Registered Member
    Join Date
    Mar 2010
    Posts
    121
    Thanks given
    12
    Thanks received
    9
    Rep Power
    24
    Quote Originally Posted by Silent Bob View Post
    You wrote a really shitty select query.

    Use prepared statements and don't use terms you don't fucking know...
    This was a 5 minute job, for anyone who wants to start on SQL.
    I'm not going to spoon feed anyone a proper method or my current SQL databases OR querys.

    I've done two years at Uni mate, read several books on Java and SQL.
    I topped my class in year 12 programming.

    If you can do better, explain.
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Replies: 1
    Last Post: 12-30-2010, 12:23 PM
  2. Replies: 2
    Last Post: 03-23-2010, 10:17 PM
  3. Replies: 23
    Last Post: 09-10-2009, 03:29 AM
  4. Replies: 26
    Last Post: 03-13-2009, 07:49 PM
  5. Replies: 20
    Last Post: 06-06-2008, 12:04 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •