NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

private static String surucu = "org.apache.derby.jdbc.EmbeddedDriver"; ConnectionToDb.JAVA
private static String yol = "jdbc:derby:market;create=true";
private static String kullaniciAdi = "";
private static String parola = "";
static { try {
Class.forName(surucu);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace(); } }
public static Connection getConnection() {
Connection baglanti = null;
try {
baglanti = DriverManager.getConnection(yol, kullaniciAdi, parola);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace(); } return baglanti; } }



public class AnaPencereGui extends JFrame { AnaPencereGui.JAVA

public AnaPencereGui() {
initPencere();
}

private void initPencere() {

setJMenuBar(initMenuBar());

setTitle("Alyaka Market");
setSize(500, 500);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocationRelativeTo(null);
setVisible(true);
}

private JMenuBar initMenuBar() {
JMenuBar menuBar = new JMenuBar();

JMenu markaJMenu = new JMenu("Marka");
JMenuItem markalarItem = new JMenuItem("Markalar");

menuBar.add(markaJMenu);
markaJMenu.add(markalarItem);

JMenu urunJMenu = new JMenu("Ürün");
JMenuItem urunlerJMenuItem = new JMenuItem("Ürünler");

menuBar.add(urunJMenu);
urunJMenu.add(urunlerJMenuItem);

JMenu turuJMenu = new JMenu("Türü");
JMenuItem turlerItem = new JMenuItem("Türler");

menuBar.add(turuJMenu);
turuJMenu.add(turlerItem);


markalarItem.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent arg0) {
SwingUtilities.invokeLater(new Runnable() {

@Override
public void run() {
MarkaGui markaGui = new MarkaGui();

}
});

}
});





public class MarkaDao { MarkaDao.JAVA

public static void tabloyuOlustur() {
Connection baglanti = ConnectionToDb.getConnection();
try {
Statement sorgu = baglanti.createStatement();

sorgu.executeUpdate(
"CREATE TABLE marka(id INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY(START WITH 1, INCREMENT BY 1), adi VARCHAR(50))");

sorgu.close();
baglanti.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
// e.printStackTrace();
}

}

public static void ekle(MarkaDomain eklenecekMarkaDomain) {

Connection baglanti = ConnectionToDb.getConnection();
try {
PreparedStatement sorgu = baglanti.prepareStatement("INSERT INTO marka(adi) VALUES(?)");
sorgu.setString(1, eklenecekMarkaDomain.getAdi());

sorgu.executeUpdate();

sorgu.close();
baglanti.close();

} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}

public static void sil(MarkaDomain silinecekMarkaDomain) {

Connection baglanti = ConnectionToDb.getConnection();
try {
PreparedStatement sorgu = baglanti.prepareStatement("DELETE FROM marka WHERE id = ?");
sorgu.setInt(1, silinecekMarkaDomain.getId());

sorgu.executeUpdate();

sorgu.close();
baglanti.close();

} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}

public static void duzenle(MarkaDomain duzenlenecekMarkaDomain) {

Connection baglanti = ConnectionToDb.getConnection();
try {
PreparedStatement sorgu = baglanti.prepareStatement("UPDATE marka SET adi = ? WHERE id = ?");
sorgu.setString(1, duzenlenecekMarkaDomain.getAdi());
sorgu.setInt(2, duzenlenecekMarkaDomain.getId());

sorgu.executeUpdate();

sorgu.close();
baglanti.close();

} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}

public static List<MarkaDomain> listele() {

List<MarkaDomain> liste = new ArrayList<MarkaDomain>();

Connection baglanti = ConnectionToDb.getConnection();
try {
Statement sorgu = baglanti.createStatement();

ResultSet sonuclar = sorgu.executeQuery("SELECT * FROM marka ORDER BY adi ASC");

while (sonuclar.next()) {
MarkaDomain siradakiMarkaDomain = new MarkaDomain();
siradakiMarkaDomain.setId(sonuclar.getInt("id"));
siradakiMarkaDomain.setAdi(sonuclar.getString("adi"));
liste.add(siradakiMarkaDomain);
}

sorgu.close();
baglanti.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

return liste;
}

public static MarkaDomain bul(String adi) {

MarkaDomain bulunanMarkaDomain = new MarkaDomain();

Connection baglanti = ConnectionToDb.getConnection();
try {
PreparedStatement sorgu = baglanti.prepareStatement("SELECT * FROM marka WHERE adi = ?");
sorgu.setString(1, adi);

ResultSet rs = sorgu.executeQuery();

while (rs.next()) {
bulunanMarkaDomain.setId(rs.getInt("id"));
bulunanMarkaDomain.setAdi(rs.getString("adi"));
}

sorgu.close();
baglanti.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

return bulunanMarkaDomain;
}

public static MarkaDomain bul(int markaId) {

MarkaDomain bulunanMarkaDomain = new MarkaDomain();

Connection baglanti = ConnectionToDb.getConnection();
try {
PreparedStatement sorgu = baglanti.prepareStatement("SELECT * FROM marka WHERE id = ?");
sorgu.setInt(1, markaId);

ResultSet rs = sorgu.executeQuery();

while (rs.next()) {
bulunanMarkaDomain.setId(rs.getInt("id"));
bulunanMarkaDomain.setAdi(rs.getString("adi"));
}

sorgu.close();
baglanti.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

return bulunanMarkaDomain;
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.