Ceriwis  

Go Back   Ceriwis > HOBI > Komputer & Teknologi > Programming

Programming Share, tanya jawab, saling bantu antar programmer dengan berbagai macam bahasa pemrograman.

Reply
 
Thread Tools
  #1  
Old 20th November 2011
Guesuper Guesuper is offline
Ceriwiser
 
Join Date: Nov 2011
Posts: 408
Rep Power: 14
Guesuper mempunyai hidup yang Normal
Default [ask] koneksi di netbeans

buat parasesepuh java netbeans ane kesulitan neh udah gelap kayaknya

udah buka tutorial punya agan hari sama agan eko tetep aja bengong.

di coba di ulik ada aja erornya



buat para sesepuh tolong beri tahu dong step stepnya dengan katakata

ato barangkali punya modul untuk nubitol macam ane bisa dibagi juga gan



untuk para sesepuh dimohon bimbingannya

tersedia + abu abu dari ane klo masalah ane terpecahkan



database yang di gunakan adalah coba dengan tabel coba12


Spoiler for code formnya:





Quote:






Code:

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/*
* coba.java
*
* Created on 21 Jul 10, 14:59:13
*/

package testing;

import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.JToolBar;
import javax.swing.table.DefaultTableModel;

/**
*
* @author Ridwan
*/
public class coba extends javax.swing.JFrame {

private static final long serialVersionUID = 1L;
private JPanel jContentPane = null;
private JToolBar jJToolBarBar = null;
private JScrollPane jScrollPane = null;
private boolean newcopy12;
private JTable table = null;
private jdbc manager = null;



/** Creates new form coba */
public coba() {
initComponents();
}

/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
//
private void initComponents() {

coba1 = new javax.swing.JTextField();
jScrollPane1 = new javax.swing.JScrollPane();
coba22 = new javax.swing.JTable();
jButton2 = new javax.swing.JButton();
coba2 = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstan ts.EXIT_ON_CLOSE);

coba1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
coba1ActionPerformed(evt);
}
});

coba22.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null},
{null, null},
{null, null},
{null, null}
},
new String [] {
"coba1", "coba2"
}
));
coba22.addInputMethodListener(new java.awt.event.InputMethodListener() {
public void caretPositionChanged(java.awt.event.InputMethodEve nt evt) {
}
public void inputMethodTextChanged(java.awt.event.InputMethodE vent evt) {
coba22InputMethodTextChanged(evt);
}
});
jScrollPane1.setViewportView(coba22);

jButton2.setText("reset");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});

jLabel1.setText("cb1");

jLabel2.setText("cb2");

jButton1.setText("jButton1");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILI NG, layout.createSequentialGroup()
.addContainerGap(15, Short.MAX_VALUE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 375, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
.addGroup(javax.swing.GroupLayout.Alignment.TRAILI NG, layout.createSequentialGroup()
.addContainerGap(266, Short.MAX_VALUE)
.addComponent(jButton2)
.addGap(77, 77, 77))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILI NG, layout.createSequentialGroup()
.addContainerGap(125, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
.addComponent(coba1, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1))
.addGap(73, 73, 73)
.addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
.addComponent(jLabel2)
.addComponent(coba2, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(75, 75, 75))
.addGroup(layout.createSequentialGroup()
.addGap(70, 70, 70)
.addComponent(jButton1)
.addContainerGap(257, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILI NG, layout.createSequentialGroup()
.addContainerGap(29, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(jLabel1))
.addPreferredGap(javax.swing.LayoutStyle.Component Placement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
.addComponent(coba2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(coba1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(11, 11, 11)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(125, 125, 125)
.addComponent(jButton2))
.addGroup(layout.createSequentialGroup()
.addGap(102, 102, 102)
.addComponent(jButton1)))
.addGap(95, 95, 95))
);

pack();
}//

private void coba1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}

private JTable getTable() {
if (coba22 == null) {
DefaultTableModel model = new DefaultTableModel(null, new String[] {
"coba1", "coba2"});
coba22 = new JTable(model);
}
return coba22;
}




private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:


}

private void coba22InputMethodTextChanged(java.awt.event.InputM ethodEvent evt) {
// TODO add your handling code here:

}

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
coba coba = new coba();
coba.setcoba1(Integer.parseInt(coba1.getText()));
coba.setcoba2(coba2.getText());

String sql = "";
if (newcoba12){
sql = "INSERT INTO coba12 (N_coba1, S_coba2)" +
" VALUES ("+coba12.getcoba1()+",'"+coba12.getcoba2()+")";
}
else {
sql = "UPDATE coba12 SET S_coba2 = '"+coba12.getcoba1()+"',"+
"N_coba2 = "+coba12.getcoba2();
}

dispose();

}

public jdbc getManager() {
if (manager == null) {
manager = new jdbc();
}
return manager;
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
coba thisClass = new coba();
thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_ CLOSE);
thisClass.setVisible(true);

}

private JTextField getcoba1() {
if (coba2 == null) {
coba1 = new JTextField();
txtId.setColumns(10);
}
return txtId;
}

});

}

// Variables declaration - do not modify
private javax.swing.JTextField coba1;
private javax.swing.JTextField coba2;
private javax.swing.JTable coba22;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JScrollPane jScrollPane1;
// End of variables declaration

}

















Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


 


All times are GMT +7. The time now is 05:50 AM.


no new posts