wenn es wer weiter coden will: (ist eig ganz fertig, nur der item code stimmt noch net ganz ( sollte man aber mit bissl zeit hinbekommen und den fehler finden) und die items müssen noch in die hashmap eingetragen werden (bis jetzt ist nur ein mithril blade drinnen)))
warum stell ich das rein? weil ich keine zeit hab, und aber auch net will das alles umsonst ist.viell findet sich ja wer. wenn ich wirklich noch zeit finde vollende ich es eventuell
Code:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.*;
public class Item
{
Item()
{
}
public static void create()
{
String complete;
StringBuilder citem = new StringBuilder();
citem.append("0x00004700002800000000000000000000");
HashMap<String, String> item2 = new HashMap<String, String>();
HashMap<String, String> slot = new HashMap<String, String>();
HashMap<String, String> attribut = new HashMap<String, String>();
HashMap<String, String> craftbonus = new HashMap<String, String>();
HashMap<String, String> slot1 = new HashMap<String, String>();
HashMap<String, String> slot2 = new HashMap<String, String>();
HashMap<String, String> craftatt = new HashMap<String, String>();
item2.clear();
slot.clear();
attribut.clear();
craftbonus.clear();
slot1.clear();
slot2.clear();
craftatt.clear();
craftbonus.put("Sword Amp","8");
craftbonus.put("Magic Amp","9");
craftbonus.put("Deathblow(Rate)","5");
craftbonus.put("Deathblow(DMG)","4");
craftatt.put("3%","9");
craftatt.put("4%","A");
craftatt.put("5%","B");
craftatt.put("8%","C");
slot1.put("Sword Amp", "18");
slot2.put("Sword Amp", "18");
slot1.put("Magic Amp", "19");
slot2.put("Magic Amp", "19");
slot1.put("Crit DMG", "14");
slot2.put("Crit DMG", "14");
slot1.put("Crit Rate", "15");
slot2.put("Crit Rate", "15");
item2.put("Mithril Blade","46");
attribut.put("+0", "0");
attribut.put("+1", "3");
attribut.put("+2", "5");
attribut.put("+3", "7");
attribut.put("+4", "9");
attribut.put("+5", "B");
attribut.put("+6", "D");
attribut.put("+7", "F");
slot.put("0 Slot", "00");
slot.put("1 Slot", "10");
slot.put("2 Slot", "20");
citem.replace(2,5,item2.get(PSDBSetter.box_itemid.getSelectedItem())); //Itemcode hinzufügen
citem.replace(4,4,attribut.get(PSDBSetter.box_attribut.getSelectedItem())); //Itemcode hinzufügen
citem.replace(20,22,slot.get(PSDBSetter.box_slot.getSelectedItem())); //Slotcode hinzufügen
if(slot1.get(PSDBSetter.box_slot1inhalt.getSelectedItem()) == slot2.get(PSDBSetter.box_slot2inhalt.getSelectedItem()) && PSDBSetter.box_slot.getSelectedItem() == "2 Slot")
{
citem.replace(14, 16, slot1.get(PSDBSetter.box_slot1inhalt.getSelectedItem()));
citem.replace(14,15,"2");
}
else
{
if(slot1.get(PSDBSetter.box_slot1inhalt.getSelectedItem()) != slot2.get(PSDBSetter.box_slot2inhalt.getSelectedItem()) && PSDBSetter.box_slot.getSelectedItem() == "2 Slot")
{
citem.replace(14, 16, slot1.get(PSDBSetter.box_slot1inhalt.getSelectedItem()));
citem.replace(16, 18, slot2.get(PSDBSetter.box_slot2inhalt.getSelectedItem()));
}
if(PSDBSetter.box_slot.getSelectedItem() == "1 Slot")
citem.replace(14, 16, slot1.get(PSDBSetter.box_slot1inhalt.getSelectedItem()));
if(PSDBSetter.box_slot.getSelectedItem() == "0 Slot")
citem.replace(14, 16, "00");
}
citem.replace(18, 19, craftatt.get(PSDBSetter.jComboBox1.getSelectedItem()));
citem.replace(19, 20, craftbonus.get(PSDBSetter.box_craftbonus.getSelectedItem()));
PSDBSetter.ausgabe.append(citem.toString()+"n");
complete = citem.toString();
String dbip;
String dbuser;
String dbpw;
dbip = PSDBSetter.t_db_ip.getText()+";databaseName=GAMEDB";
dbuser = PSDBSetter.t_db_user.getText();
dbpw = PSDBSetter.t_db_pw.getText();
Connection dbVerbindung=null;
Statement sqlStatement=null;
String sqlString="exec dbo.cabal_tool_SetInventory "+PSDBSetter.t_charid.getText()+", "+complete;
ResultSet resultSet=null;
try
{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
PSDBSetter.ausgabe.append("Datenbanktreiber erfolgreich geladen..."+"n");
}
catch(ClassNotFoundException e)
{
PSDBSetter.ausgabe.append("Fehler beim Laden des Treibers"+e+"n");
}
try
{
dbVerbindung = DriverManager.getConnection("jdbc:microsoft:sqlserver://"+dbip,dbuser,dbpw);
PSDBSetter.ausgabe.append("Verbindung zur CabalDatenbank erfolgreich..."+"n");
}
catch(SQLException e)
{
PSDBSetter.ausgabe.append("DB-Verbindungsfehler:nKonnte keine Verbindung zur Datenbank herstellenn");
}
try
{
sqlStatement = dbVerbindung.createStatement();
PSDBSetter.ausgabe.append("SQL-Statement erzeugt..."+"n");
resultSet = sqlStatement.executeQuery(sqlString);
PSDBSetter.ausgabe.append("resultSet-Objekt geschlossen..."+"n");
PSDBSetter.ausgabe.append("sqlStatement-Objekt geschlossen..."+"n");
PSDBSetter.ausgabe.append("Verbindung geschlossen..."+"n");
PSDBSetter.ausgabe.append("Item übertragen!"+"n");
sqlStatement.close();
resultSet.close();
dbVerbindung.close();
}
catch(SQLException e)
{
PSDBSetter.ausgabe.append("scheisse xD " + e);
}
}
}
Code:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
/*
* PSDBSetter.java
*
* Created on 27. Juli 2008, 23:52 by Lowi
*/
/**
*
* @author Lowi
*/
public class PSDBSetter extends javax.swing.JFrame {
public PSDBSetter() {
initComponents();
}
private void initComponents() {
header = new javax.swing.JLabel();
t_db_ip = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
t_db_user = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
t_db_pw = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
t_db_char = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
button_getCharID = new javax.swing.JButton();
t_charid = new javax.swing.JTextField();
jLabel5 = new javax.swing.JLabel();
box_itemid = new javax.swing.JComboBox();
jLabel6 = new javax.swing.JLabel();
box_slot = new javax.swing.JComboBox();
jLabel7 = new javax.swing.JLabel();
button_create = new javax.swing.JButton();
box_craftbonus = new javax.swing.JComboBox();
jLabel8 = new javax.swing.JLabel();
box_slot1inhalt = new javax.swing.JComboBox();
jLabel9 = new javax.swing.JLabel();
box_slot2inhalt = new javax.swing.JComboBox();
jLabel10 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
ausgabe = new javax.swing.JTextArea();
box_attribut = new javax.swing.JComboBox();
jLabel11 = new javax.swing.JLabel();
jComboBox1 = new javax.swing.JComboBox();
jLabel12 = new javax.swing.JLabel();
jLabel13 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Cabal Private Server Item Setter");
header.setBackground(new java.awt.Color(51, 102, 255));
header.setFont(new java.awt.Font("Bradley Hand ITC", 1, 24));
header.setText("Cabal Private Server Item Creator");
header.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 2, true));
jLabel1.setFont(new java.awt.Font("Bookman Old Style", 1, 12));
jLabel1.setText("::DB IP::");
jLabel2.setFont(new java.awt.Font("Bookman Old Style", 1, 12));
jLabel2.setText("::DB USER::");
jLabel3.setFont(new java.awt.Font("Bookman Old Style", 1, 12));
jLabel3.setText("::DB PW::");
jLabel4.setFont(new java.awt.Font("Bookman Old Style", 1, 12));
jLabel4.setText("::Char Name::");
button_getCharID.setText("get Char ID");
button_getCharID.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
button_getCharIDMouseClicked(evt);
}
});
jLabel5.setText("(Character ID)");
box_itemid.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Mithril Blade" }));
jLabel6.setFont(new java.awt.Font("Bookman Old Style", 1, 12));
jLabel6.setText("::Item");
box_slot.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0 Slot", "1 Slot", "2 Slot" }));
jLabel7.setFont(new java.awt.Font("Bookman Old Style", 1, 12));
jLabel7.setText("::Slot Anzahl");
button_create.setText("Create Item");
button_create.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
button_createMouseClicked(evt);
}
});
box_craftbonus.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Sword Amp","Magic Amp","Deathblow(Rate)","Deathblow(DMG)" }));
jLabel8.setFont(new java.awt.Font("Bookman Old Style", 1, 12));
jLabel8.setText("::Craft Bonus");
box_slot1inhalt.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Sword Amp", "Magic Amp", "Crit DMG", "Crit Rate" }));
jLabel9.setFont(new java.awt.Font("Bookman Old Style", 1, 12));
jLabel9.setText("::Slot#1 Inhalt");
box_slot2inhalt.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Sword Amp", "Magic Amp", "Crit DMG", "Crit Rate" }));
jLabel10.setFont(new java.awt.Font("Bookman Old Style", 1, 12));
jLabel10.setText("::Slot#2 Inhalt");
ausgabe.setColumns(20);
ausgabe.setRows(5);
ausgabe.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
jScrollPane1.setViewportView(ausgabe);
box_attribut.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "+0", "+1", "+2", "+3", "+4", "+5", "+6", "+7" }));
jLabel11.setFont(new java.awt.Font("Bookman Old Style", 1, 12));
jLabel11.setText("::+ ?");
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "3%", "4%", "5%", "8%" }));
jComboBox1.setToolTipText("3% Amp/Rate = 4% Crit DMG // 4% Amp/Rate = 7% Crit DMG // 5% Amp/Rate = 10% Crit DMG // 8% Amp/Rate = 16% Crit DMG");
jLabel12.setFont(new java.awt.Font("Bookman Old Style", 1, 12));
jLabel12.setText("::% ?");
jLabel13.setText("(c) by Lowi");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(header)
.addGap(131, 131, 131))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(t_db_ip, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(t_db_user, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jLabel7, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(box_slot, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(box_slot1inhalt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel9)
.addComponent(box_slot2inhalt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel10)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(box_itemid, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(box_craftbonus, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel8))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 19, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel12)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel11)
.addComponent(box_attribut, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(t_db_pw, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel4)
.addGroup(layout.createSequentialGroup()
.addComponent(t_db_char, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(button_getCharID)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(t_charid, javax.swing.GroupLayout.DEFAULT_SIZE, 45, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel5))))
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 364, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(61, 61, 61))
.addGroup(layout.createSequentialGroup()
.addGap(178, 178, 178)
.addComponent(button_create)
.addContainerGap()))))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jLabel13)
.addContainerGap())))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(header)
.addGap(11, 11, 11)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(jLabel3)
.addComponent(jLabel4)
.addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(t_db_ip, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(t_db_user, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(t_db_pw, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(button_getCharID)
.addComponent(jLabel5)
.addComponent(t_db_char, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(t_charid, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup()
.addGap(22, 22, 22)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel6)
.addComponent(jLabel11))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(box_itemid, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(box_attribut, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(17, 17, 17)
.addComponent(jLabel7)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(box_slot, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(22, 22, 22)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel8)
.addComponent(jLabel12))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(box_craftbonus, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(26, 26, 26)
.addComponent(jLabel9)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(box_slot1inhalt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(26, 26, 26)
.addComponent(jLabel10))
.addGroup(layout.createSequentialGroup()
.addGap(19, 19, 19)
.addComponent(jScrollPane1)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(box_slot2inhalt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(button_create))
.addGap(33, 33, 33)
.addComponent(jLabel13)
.addContainerGap())
);
pack();
}
private void button_createMouseClicked(java.awt.event.MouseEvent evt) {
Item.create();
}
private void button_getCharIDMouseClicked(java.awt.event.MouseEvent evt) {
getCharID();
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new PSDBSetter().setVisible(true);
}
});
}
static javax.swing.JTextArea ausgabe;
static javax.swing.JComboBox box_attribut;
static javax.swing.JComboBox box_craftbonus;
static javax.swing.JComboBox box_itemid;
static javax.swing.JComboBox box_slot;
static javax.swing.JComboBox box_slot1inhalt;
static javax.swing.JComboBox box_slot2inhalt;
static javax.swing.JButton button_create;
static javax.swing.JButton button_getCharID;
static javax.swing.JLabel header;
static javax.swing.JComboBox jComboBox1;
static javax.swing.JLabel jLabel1;
static javax.swing.JLabel jLabel10;
static javax.swing.JLabel jLabel11;
static javax.swing.JLabel jLabel12;
static javax.swing.JLabel jLabel13;
static javax.swing.JLabel jLabel2;
static javax.swing.JLabel jLabel3;
static javax.swing.JLabel jLabel4;
static javax.swing.JLabel jLabel5;
static javax.swing.JLabel jLabel6;
static javax.swing.JLabel jLabel7;
static javax.swing.JLabel jLabel8;
static javax.swing.JLabel jLabel9;
static javax.swing.JScrollPane jScrollPane1;
static javax.swing.JTextField t_charid;
static javax.swing.JTextField t_db_char;
static javax.swing.JTextField t_db_ip;
static javax.swing.JTextField t_db_pw;
static javax.swing.JTextField t_db_user;
public void getCharID()
{
String dbip;
String dbuser;
String dbpw;
dbip = t_db_ip.getText()+";databaseName=GAMEDB";
dbuser = t_db_user.getText();
dbpw = t_db_pw.getText();
Connection dbVerbindung=null;
Statement sqlStatement=null;
String sqlString="SELECT CharacterIdx FROM cabal_character_table WHERE Name = '"+t_db_char.getText()+"'";
ResultSet resultSet=null;
try
{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
ausgabe.append("Datenbanktreiber erfolgreich geladen..."+"n");
}
catch(ClassNotFoundException e)
{
ausgabe.append("Fehler beim Laden des Treibers"+e+"n");
}
try
{
dbVerbindung = DriverManager.getConnection("jdbc:microsoft:sqlserver://"+dbip,dbuser,dbpw);
ausgabe.append("Verbindung zur CabalDatenbank erfolgreich..."+"n");
}
catch(SQLException e)
{
ausgabe.append("DB-Verbindungsfehler:nKonnte keine Verbindung zur Datenbank herstellenn");
}
try
{
sqlStatement = dbVerbindung.createStatement();
ausgabe.append("SQL-Statement erzeugt..."+"n");
resultSet = sqlStatement.executeQuery(sqlString);
ausgabe.append("resultSet-Objekt geschlossen..."+"n");
ausgabe.append("sqlStatement-Objekt geschlossen..."+"n");
ausgabe.append("Verbindung geschlossen..."+"n");
while(resultSet.next() == true)
t_charid.setText(resultSet.getString(1));
sqlStatement.close();
resultSet.close();
dbVerbindung.close();
}
catch(SQLException e)
{
ausgabe.append("Konnte den Spielernamen nicht finden!"+"n");
}
}
}