27 Mayıs 2020 Çarşamba

Dentist Implants


DENTIST IMPLANTS HEALTH SERVICES INDUSTRY LIMITID COMPENY  is founded at 2013 in Turkey. We work for our peoples dental health, at the same time, we support international dental health tourism for everyone around the world. The dental hospitals and polyclinics which we has contracted are 6 baks and above. Our  doctors use the most advanced new technology during the treatment .

23 Kasım 2019 Cumartesi

Adana Gürselpaşa Nakliyat



Gürselpaşa mahallesinde Evden Eve Taşıma ve Parça Eşya taşıma hizmetini yapan Nakliyeci Fatih YILIK'a bu telefon numarsından ulaşabilirsiniz : +90 551 012 50 20


17 Kasım 2016 Perşembe

SQL Server Stored Procedure Oluşuturma

Daha Önceki dersimiz'de MySQL ile Stored Procedure oluşturmaktan bahsetmiştim bu dersimiz'de ise SQL Server üzerinde bu işlem nasıl yapılır ona değineceğim... 

İlk önce SQL Server'a bağlanıp işlem yapmak istediğimiz Database'in içerisine giriyoruz... 

  1. Ardından Programmability > Stored Procedure > New > Stored Procedure... tıklıyoruz
  2. Ardından Açılan Pencerede karşımıza aşadağı gibi bir görüntü çıkmaktadır;
  3. -- ================================================
    -- Template generated from Template Explorer using:
    -- Create Procedure (New Menu).SQL
    --
    -- Use the Specify Values for Template Parameters
    -- command (Ctrl-Shift-M) to fill in the parameter
    -- values below.
    --
    -- This block of comments will not be included in
    -- the definition of the procedure.
    -- ================================================
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    -- =============================================
    -- Author:          <Author,,Name>
    -- Create date: <Create Date,,>
    -- Description:     <Description,,>
    -- =============================================
    CREATE PROCEDURE <Procedure_Name, sysname, ProcedureName>
           -- Add the parameters for the stored procedure here
           <@Param1, sysname, @p1> <Datatype_For_Param1, , int> = <Default_Value_For_Param1, , 0>,
           <@Param2, sysname, @p2> <Datatype_For_Param2, , int> = <Default_Value_For_Param2, , 0>
    AS
    BEGIN
           -- SET NOCOUNT ON added to prevent extra result sets from
           -- interfering with SELECT statements.
           SET NOCOUNT ON;

        -- Insert statements for procedure here
           SELECT <@Param1, sysname, @p1>, <@Param2, sysname, @p2>
    END
    GO

  4. Ardından karşımıza çıkan görüntüde bazı temizlikler yapacağız ve bu doğrultuda procedure'müzü yazacağız...
  5. Temizlenmiş hali işte görüntüde gibidir; 
  6. SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO

    CREATE PROCEDURE <Procedure_Name, sysname, ProcedureName>
           
    AS
    BEGIN
    END
    GO 
  7. Buraya kadar olan her şeyi temizliyoruz sadece bu kadar kısım kalmalı
  8. Bu işlemleri gerçekleştirdikten sonra procedumuzda bir listeleme işlemi gerçekleştirelim.
USE [BBYS2]
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[sel_Deneme]
      
AS
BEGIN
      
       Select *From Faculty
END

Procedure müzü yazdıktan sonra derle buttonuna basıyoruz resimde ki gibi; 

Kısaca SQL Server'da procedure oluşturma bu şekilde bir sonra ki derste görüşmek üzere 
İyi günler



MySQL (Phpmyadmin) ile Stored Procedure Oluşturma

Merhaba arkadaşlar bugün ki dersimizde Mysql ile Stored Procedure oluşturmaktan bahedeceğim. Yalnız konuya girmeden önce nedir bu Stored Procedure ona değinelim. Stored Procedure'ün kelime manası Saklı yordam demektir. Peki ne işe yarar Stored Procedure'ler ?
Stored Procedure'ler ilk akla gelen önemi Güvenlik açıklarını minimize etmek amacıyla kullanılmaktadır. Peki hangi güvenlik önlemleri için kullanılır ?
Madde halinde verecek olursak;

  1. Veritabanına karşı yapılan sql injection'larına karşı koymak için yapılır... 
  2. Örneğin projenizi decompiler yapan bir hacker'ın veritabanı kodlarını açık bir şekilde görmemmesi amacıyla bir maskeleme yöntemi de diyebiliriz. 
Kısaca  Stored Procedure'ler bu amaçla kullanılır... 
Peki MySQL'de nasıl kullanılır ? 

localhost/phpmyadmin'e erişerek Yordamlar > Yeni Yordam Ekle'ye tıklayarak yordam ekleme sayfası karşınıza çıkacaktır...
Yapmak  istediğiniz Procedure türünü buradan belirleyip git dediğinizde procedure'u oluşturmuş oluyorsunuz.

11 Kasım 2016 Cuma

JList'ten Alınan Value Değerine Göre JTable'da Listeleme Yapmak(Parametrik Listeleme)


Öncelikle veritabanı kodlarımızla başlayalım;

SELECT product.productId, product.productName ,category.categoryName,category.categoryId,product.price
               FROM product
               LEFT JOIN category on product.categoryId=category.categoryId

WHERE category.categoryId="değer"

Yazmış olduğum SQL Cümlesinde Product ve Category adlı tabloları LEFT JOIN aracılığı ile birbirine bağladık. Ardından ise JList'ten gelecek verinin değerini karşılaması için WHERE operatörünü kullandık... Test ettik MYSQL'de çalışıyor. 

Ardından ise bunu Java kısmına uyarlıyoruz Aşağıda ki gibi; 

public static List<ProductDomain> categoryList(int a) {
List<ProductDomain> selectItem = new ArrayList<ProductDomain>();
Connection conn = ConnectionDao.getConnnection();
try {
       Statement query = conn.createStatement();
ResultSet rs = query.executeQuery("SELECT product.productId, product.productName,category.categoryName,category.categoryId,product.price "
                                               
+ "FROM product " 
+ "LEFT JOIN category on product.categoryId=category.categoryId "                       
+ "WHERE category.categoryId=" + a + "");

   while (rs.next()) {

   ProductDomain sec = new ProductDomain();
                          
   sec.setCategoryId(rs.getInt("category.categoryId"));
   sec.setProductId(rs.getInt("product.productId"));
   sec.setProductName(rs.getString("product.productName"));
   sec.setCategoryName(rs.getString("category.categoryName"));
   sec.setPrice(rs.getDouble("price"));
 selectItem.add(sec);
}
Ardından ise arayüz kısmına geçip  JList'te yapılan hareketle bir faliyete geçmesi için JList'te addListSelectionListener metodunu uygulayacağım... 

Aşağıda ki gibi; 

productCategoryList.addListSelectionListener(new ListSelectionListener() {
                   
                    @Override
                    public void valueChanged(ListSelectionEvent e) {
                           // TODO Auto-generated method stub
                          
                    }
             });

Ardından oluşturduğum Listener'ın içine JList'i cast ediyorum; 

CategoryDomain categoryDm = (CategoryDomain) productCategoryList.getSelectedValue();

Ardından ise; cast ederek aldığım değeri bir Integer değişkene atıyorum. 
int a = categoryDm.getCategoryId();
Ardından

for ile SQL kısmında oluşturduğum methodu yani yukarıda ki metodu aşağıda ki gibi kullanarak yazıyorum; 

for (ProductDomain dm : ProductDao.categoryList(a)) {

     Object variable[] = { dm.getProductId(), dm.getProductName(), dm.getCategoryName(), dm.getPrice() };
model.addRow(variable);

                           }
 Tam hali aşağıda ki gibidir; 

productCategoryList.addListSelectionListener(new ListSelectionListener() {

                    @Override
                    public void valueChanged(ListSelectionEvent arg0) {
                          
                           int rowCount = model.getRowCount();
                           //JTable'ın içinde ki geçmiş model  verilerini temizler yenilerini tekrar for ile yerleştirir
                           for (int i = rowCount - 1; i >= 0; i--) {
                                  model.removeRow(i);
                           }

                           CategoryDomain categoryDm = (CategoryDomain) productCategoryList.getSelectedValue();
                           int a = categoryDm.getCategoryId();

                           for (ProductDomain dm : ProductDao.categoryList(a)) {

                                  Object variable[] = { dm.getProductId(), dm.getProductName(), dm.getCategoryName(), dm.getPrice() };
                                  model.addRow(variable);

                           }

                    }
             });



8 Kasım 2016 Salı

Java'da ComboBox'ları Parametreye Göre Otomatik Seçtirme


Merhaba değerli takipçilerimiz bugün Java'da birbirine bağlı bir şekilde seçtiğimizde alt Combo'ları açılan ComboBox'a değineceğiz.

1. Adım Domain 

ProductDomain.java;  

package tr.com.ny.dm;

public class ProductDomain {

       int productId;
       int categoryId;
       double price;
       String productName;
       String productDescription;
       String categoryName;

       public int getProductId() {
             return productId;
       }

       public void setProductId(int productId) {
             this.productId = productId;
       }

       public int getCategoryId() {
             return categoryId;
       }

       public void setCategoryId(int categoryId) {
             this.categoryId = categoryId;
       }

       public double getPrice() {
             return price;
       }

       public void setPrice(double price) {
             this.price = price;
       }

       public String getProductName() {
             return productName;
       }

       public void setProductName(String productName) {
             this.productName = productName;
       }

       public String getProductDescription() {
             return productDescription;
       }

       public void setProductDescription(String productDescription) {
             this.productDescription = productDescription;
       }

       public String getCategoryName() {
             return categoryName;
       }

       public void setCategoryName(String categoryName) {
             this.categoryName = categoryName;
       }

       public String toString() {

             return productName;

       }

       public Object[] getData() {

             Object[] data = { productId, productName, categoryName, productDescription };

             return data;

       }

}

1. Adım Veritabanı ve Arayüz
ProductDao.java

1. Method; Normal Listeleme; 
public static List<ProductDomain> selectProduct() {

             List<ProductDomain> list = new ArrayList<ProductDomain>();

             Connection conn = ConnectionDao.getConnnection();

             try {

                    ProductDomain selectCategory = null;
                    Statement query = conn.createStatement();

                    ResultSet rs = query.executeQuery("SELECT product.productId,product.productName, category.categoryName, product.price, product.price,product.productDescription "
                                               + "FROM product " + "LEFT JOIN Category ON product.categoryId=category.categoryId");

                    while (rs.next()) {
                           selectCategory = new ProductDomain();

                           selectCategory.setProductId(rs.getInt("product.productId"));
                           selectCategory.setProductName(rs.getString("product.productName"));
                           selectCategory.setCategoryName(rs.getString("category.categoryName"));
                           selectCategory.setPrice(rs.getDouble("product.price"));
                           selectCategory.setProductDescription(rs.getString("product.productDescription"));

                           list.add(selectCategory);

                    }

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

             return list;

       }



1. Metot Arayüz'de ComboBox'ın içinde çağırma; 

productNameBox.addItemListener(new ItemListener() {

                    @Override
                    public void itemStateChanged(ItemEvent arg0) {
                           productPriceBox.removeAllItems();
                           productCategoryBox.removeAllItems();
                           ProductDomain list = (ProductDomain) productNameBox.getSelectedItem();
                          
                           productPriceBox.addItem(list.getPrice());
                           productCategoryBox.addItem(list.getCategoryName());

                    }

             });

productNameBox ComboBox'ına ItemListener uygulandıktan sonra önce işlem yapmak comboBox'ları removeAllItems ile temizliyoruz ardından. Parametresini almak istediğimiz ComboBox'ı yani prodoductNameBox'ı cast ediyoruz. Ardından  Domain aracılığı ile çekmiş olduğumuz verileri comboBox'lara get ediyoruz....

Bugün ki dersimiz bu kadar bir sonra ki derste görüşmek dileğiyle.