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 .
Yazılım Dersleri | C | Java | C# | Android | JSF
27 Mayıs 2020 Çarşamba
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...
- Ardından Programmability > Stored Procedure > New > Stored Procedure... tıklıyoruz
- Ardından Açılan Pencerede karşımıza aşadağı gibi bir görüntü çıkmaktadır;
- -- ================================================-- 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 ONGOSET QUOTED_IDENTIFIER ONGO-- =============================================-- 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>ASBEGIN-- SET NOCOUNT ON added to prevent extra result sets from-- interfering with SELECT statements.SET NOCOUNT ON;-- Insert statements for procedure hereSELECT <@Param1, sysname, @p1>, <@Param2, sysname, @p2>ENDGO
- Ardından karşımıza çıkan görüntüde bazı temizlikler yapacağız ve bu doğrultuda procedure'müzü yazacağız...
- Temizlenmiş hali işte görüntüde gibidir;
- SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOCREATE PROCEDURE <Procedure_Name, sysname, ProcedureName>ASBEGINENDGO
- Buraya kadar olan her şeyi temizliyoruz sadece bu kadar kısım kalmalı
- 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
Etiketler:
C#,
Create,
Oluşturma,
SQL Server,
Stored Procedure
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;
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;
- Veritabanına karşı yapılan sql injection'larına karşı koymak için yapılır...
- Ö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);
model.addRow(variable);
}
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
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;
}
}
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;
}
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.
Kaydol:
Yorumlar (Atom)





