Professional Documents
Culture Documents
V Vn Hi's blog
Ch c mt iu tuyt i l mi th u tng i
Home C# Visual Basic Java J2EE Web My Projects XMLJ Web services My Garden SE CTDL Design Patterns About
c V Vn His Blog
S dng FireFox V3 v phn gii mn hnh cao nht c th xem blog c tt nht!
Recent Posts
La chn ngnh CNTT: Ti i lm ng hay c qu nhiu quyt nh sai tri? 10 nm nh Trnh Cng Sn: Ct bi Java hay .NET? Mt bi ton nan gii ca nhiu Newbie Chuyn c quyn Microsoft cho php ti v m ngun cc control ca Silverlight 2
Archives
Select Month
Subscribe
Entries (RSS) Comments (RSS)
Cc phn hi gn y
vovanhai.wordpress.com/java/lp-trinh-java-nang-cao//lam-vic-v i-stored-procedure/ 1/17
12/23/11
V Vn Hi on Java Web services V Vn Hi on EJB 3 V Vn Hi on C# V Vn Hi on Lp trnh java nng cao V Vn Hi on Bean-Managed Persistent Entity Beans EJB2- Student Example V Vn Hi on Java V Vn Hi on Java truong ho on TO WEB SERVICE S DNG ECLIPSE japanese1801 on Lm vic vi Text File nota on Java hay .NET? Mt bi ton nan gii ca nhiu Newbie minh on La chn ngnh CNTT: Ti i lm ng hay c qu nhiu quyt nh sai tri? qanh on Java nguyentrunghieuct on Bean-Managed Persistent Entity Beans EJB2- Student Example java on Java Nhn on La chn ngnh CNTT: Ti i lm ng hay c qu nhiu quyt nh sai tri?
Cc trang c yu thch
Lp trnh java cn bn Java C# Lp trnh java nng cao M hnh MVC v 1 v d ng dng Lm vic vi Text File Kt ni java vi SQL server C bn v Cu hnh Tomcat Lm vic vi Stored Procedure ng gi 1 ng dng java thnh file EXE ng dng duyt hnh nh vi C# Lu hnh nh vo database
Search
Ngm v ngh
ng ngh bn c bao nhiu im. ng ngh bn hc trng no. ng ngh bn tt nghip loi g.
vovanhai.wordpress.com/java/lp-trinh-java-nang-cao//lam-vic-v i-stored-procedure/ 2/17
12/23/11
Sorry
i khi v cng vic qu bn rn nn ti khng th tr li ht c tt c cc cu hi c a cc bn. Mong cc bn b qu cho. Cc bn c th tr li cc cu hi, xin gip 1 tay!
Pages
About C# ng dng duyt hnh nh vi C# ng dng m hnh 3-tiers trong C# Chng trnh nghe nhc, xem phim, xem hnh da trn WMP Gi v nhn DataTable qua Socket trong C# Lit k cc tn culture v cc nh danh trong C# Localization Internationalization (a phng ha Quc t ha Lu hnh nh vo database To playlist trong Windows Media Palyer vi C# ng gi v trin khai ng dng trong VS2005 CTDL Cp pht quyn cho chng trnh C/C++ theo hng cu trc Mt s thao tc trn danh sch lin kt n c ghi 1 mng cu trc trong C++ Design Patterns J2EE EJB Bean-Managed Persistent Entity Beans EJB2- Student Example Container-Managed Persistence Entity Beans EJB2 Employees Example DNG CMP TO ORDER Dng java authentication & authorization services(jaas) cu hnh phn quyn s dng cc bussiness methods trong ejb EJB 2.x vi NetBeans 6.7.1 & JBoss AS 4.23 GA Security vi JAAS s dng DatabaseServerLoginModule Staless Session Bean EJB2, v d 1 Staless Session Bean EJB2, v d 2 Xc nhn ng nhp Stateful Session Bean EJB2 ShoppingCart TO TRANSACTION VI BEAN-MANAGED TRANSACTION TO TRANSACTION VI CONTAINER-MANAGED TRANSACTION EJB 3 Chuyn m JDBC Data Access Objects s dng EJB3 EJB3 Entity Bean with JBOSS JPA EJB3 v d mi quan h gia cc bng trong CSDL Staless Session Bean EJB3 STATEFULL SESSION BEAN EJB3 V 1 V D V SHOPPINGCART Java Mail Gi mail c chng thc trong java c gmail vi JavaMail API JMS JMS v d lm vic vi Point-To-Point Model v Publish-and-Subscribe Model
vovanhai.wordpress.com/java/lp-trinh-java-nang-cao//lam-vic-v i-stored-procedure/ 3/17
12/23/11
V D V MESSAGE-DRIVEN BEANS TRUY XUT ENTITY BEAN V D V MESSAGE-DRIVEN BEANS N GIN RMI Cc bc to ng dng vi RMI Lit k tt c cc rmi object ng k trong 1 rmi registry Mt ng dng RMI truy xut CSDL Parameter Passing in Remote Methods Invocation Triu gi ng dng RMI trong Applet Java Lp trnh java cn bn Assignment 2008 Bi tp chng 4 Pig Game Cc bc cn bn to i tng trong java Cc bc lm vic vi tp hp cc i tng Cu hnh JDK v JCreator Code lin quan n x l Date GUI application Chuyn i giao din thnh Windows look and feel trong Java 6 Chuyn i giao din thnh Motif look and feel trong Java 6 GUI & Object trong 1 v d In n trong cc Text Component JDK6 Splash Screen To ng ng dng a ca s (Multiple Document Interface MDI) To/Hy System Tray icon Thm Mouse listener/Mouse motion listener vo TrayIcon V d v System Tray p ng chn la t user V hnh nn trn JFrame Hng dn lm vic vi Eclipse Lm vic vi Text File Lit k tt c cc tp tin c trong 1 file JAR hoc ZIP Mt chng trnh Notepad n gin vi java Object Serialization S dng text file lu tr d liu dng CSDL Thng k cc t trong mt vn bn Thc thi 1 file vi chng trnh mc nh ng gi 1 ng dng java thnh file EXE ng gi 1 ng dng thnh executable-jar file Lp trnh java nng cao Cc ch khc Bin dch 1 file java bn trong 1 chng trnh java JDBC Java Database Connectivity Biu din quan h mi quan h master-details bng JTree JTable Cc thao tc c bn trong lp trnh JDBC Chn hnh xung MS SQL server s dng GUI Chn v c hnh t c s d liu Export d liu ra Excel dng POI JTable vi cc thao tc CRUD trn c s d liu Kt ni java vi Oracle Kt ni java vi SQL server
vovanhai.wordpress.com/java/lp-trinh-java-nang-cao//lam-vic-v i-stored-procedure/ 4/17
12/23/11
Lm vic vi Stored Procedure To i tng ConnectionFactory dng cho k thut kt ni dng chung (connection-pool) Thao tc vi Metadata Updatable JTable c hnh t MS SQL server ri hin th ln JTable JPA Java Persistence API Lm vic vi JPA trong NetBean 6.1 Thit lp Eclipse JPA Project da trn Java SE s dng Hibernate Networking ng dng Tabbed Web browser ChatRoom n gin Lp trnh Socket to ng dng Calculator Thng k k t trong file v v biu My Garden m nhc Bi ht c th lm cht ngi? Cm xc Chuyn tnh Chuyn tnh con chun chun Nh ch tnh n ri hy yu Seminar Gii thiu Design Patterns Seminar J2EE6 Vui vui My Projects Sinh code t ng cho cc Entities C# SE JUnit Test trong Java NUnit Test vi Microsoft Visual Studio Testing S sng cn ca sn xut phn mm Unit Test vi Microsoft Visual Studio 2010 Unit Test vi Visual Studio 2008 Visual Basic Cn bn Class trong Visual Basic.Net Structure trong VB.Net X l mng ng trong Visual Basic.Net Web ASP.Net Windows Mobile Web Form vi Visual Studio 2008 Host ng dng web Hng dn Hosting JSP/Servlet. Qun l CSDL vi PHP MyAdmin JSF Java Server Face ComboBox trong DataGrid vi JSF EJB3 JPA JSF trong 1 v d JBoss RichFaces Cu hnh v pht trin RichFaces vi Eclipse Ganymede Dng rich:panelMenu hin th d liu ca 2 bng csdl quan h 1-n RichFaces: Logon v Registration application Cu hnh web config
vovanhai.wordpress.com/java/lp-trinh-java-nang-cao//lam-vic-v i-stored-procedure/ 5/17
12/23/11
To database cho ng dng To managed beans To project vi Eclipse To resource bundle (properties file) Thc thi ng dng Thit k cc trang JSP ng k cc managed bean v nh ngha cc navigation rules Sp xp d liu hin th trong bng Upload file trong RichFaces X l s kin trn rich:dataTable JSF Lm vic vi C S D LIU Lm vic vi JSF trong Eclipse Ganymede JSP Cc bc to 1 servlet dng JSP to 1 trang XML Cu hnh Tomcat trong NetBeans Custom Tag JSP Eclipse C bn v Cu hnh Tomcat Dng SERVLET JSP triu gi EJB Gi hng vi JSP Ly cc gi tr c lu trong th env-entry ca file web.xml Ly tt c cc Locale kh d vi java M hnh MVC v 1 v d ng dng Xy dng custom tag hin th d liu table ca 1 databse Servlet programming ng dng Servlet u tin vi Eclipse Cu hnh JDBC Realm cho Tomcat Declarative Security in Servet Form-based security in servlet Form-based security vi Tomcat users Programatic security in serlet S dng HttpSession to ng dng gi hng trong Servlet Secure web s dng HTTPS Struts Cu hnh validation cho Struts 1.29 trong NetBeans 6.1 Gi hng vi Struts v Netbeans So snh Struts 1 v Struts 2 Struts 1.x vi Eclipse Struts 1.x vi NetBeans V d Logon vi Struts 2 trn Eclipse Ganymede Web services C# Web services ng dng truy xut java Web Service Dng ASP.Net truy xut java Web Service To Web service vi C# step-by-step Gii thiu v Web Service Java Web services Consume .NET Web Service with Eclipse Consume a .NET Web Service with Axis2 tools Lm vic vi JAX-WS trong Eclipse Pht trin 1 JAX-WS EJB3 Stateless Session Bean Web Service
vovanhai.wordpress.com/java/lp-trinh-java-nang-cao//lam-vic-v i-stored-procedure/ 6/17
12/23/11
RESTful Web Service TO WEB SERVICE S DNG ECLIPSE To JSP Web Service Client To Web Service Client s dng SOAP UI Plugin To Web services vi JAX-WS 2.0 v Java SE 6 Platform Secure Web Service s dng Username Authentication with Symmetric Keys (UA) Web service Security vi NetBeans 6.x Web Service truy xut c s d liu XMLJ Chuyn Html sang XML Convert DOM to JDOM Convert DOM to SAX Convert JDOM to DOM Convert SAX to JDOM Dng DOM c file XML biu bin trn JTree Hin th XML vi mu sc theo c php Streaming API for XML (StAX) Validate ti liu kt qu ca vic transform 1 ti liu xml Validator ti liu XML XML JSP Dng DOM hin th ti liu trong JSP Dng JAXB tools chuyn i ti liu XML thnh java v ngc li Dng JSP transform ti liu XML thnh HTML Dng SAX hin th ti liu XML trn JSP Dng SAX hin th ti liu XML trn JSP vi JSPWriter XML Simple Editor XSLT Examples XSLT xsl:apply-templates Element XSLT xsl:choose Element XSLT xsl:for-each Element XSLT xsl:if Element XSLT xsl:sort Element XSLT xsl:template Element XSLT xsl:value-of Element
Blog Stats
1,207,956 hits
Email Subscription
Enter your email address to subscribe to this blog and receive notifications of new posts by email. Join 170 other followers
Sign me up!
vovanhai.wordpress.com/java/lp-trinh-java-nang-cao//lam-vic-v i-stored-procedure/
7/17
12/23/11
12/23/11
create proc exInparams @clsID varchar(15) AS select * from tblClass where tblClass.classID like @clsID GO Thc thi exec exInparams c% ******************************************** -To proc cho tham s output create proc exOutParams @cls varchar(15),@num int OUTPUT as select @num=count(classID) from tblClass where classID like @cls go Thc thi declare @s int exec exOutParams c%,@s OUTPUT print @s ******************************************** -To proc cho tham s INOUT create proc exINOUTParams @num int OUT as select @num=count(classID) from tblClass where studentsNum>@num go select * from tblClass Thc thi declare @s int set @s=100 exec exINOUTParams @s OUTPUT print @s ******************************************** Hm Function Hm ly s SV ca 1 lp khi bit m s lp create FUNCTION dbo.getNoStudents (@classID varchar(15)) RETURNS int AS BEGIN Declare @c int set @c=(select studentsNum from tblClass where classID = @classID) return @c END go Thc thi
vovanhai.wordpress.com/java/lp-trinh-java-nang-cao//lam-vic-v i-stored-procedure/ 9/17
12/23/11
declare @x int set @x=dbo.getNoStudents(cdth4c) print(@x) ******************************************** Bn to DB ri chy cc hm th trn h qun tr CSDL, chng hn MS SQLserver. bn to lp sau th cc loi:
akg oahi odrs.o; cae na. rpescm
import java.sql.CallableStatement; import java.sql.Connection; import java.sql.ResultSet; import session6_JDBC.ConnectDBFactory; //th tham s u vo public class TestCallable { private Connection con; void TestINPro() throws Exception{ con=ConnectDBFactory.CreateMsSqlServerConnection(QLSV); String sql={call exInparams(?)}; CallableStatement cstmt=con.prepareCall(sql); cstmt.setString(1, c%); ResultSet rs=cstmt.executeQuery(); while(rs.next()) { System.out.println(rs.getString(className)); } con.close(); } //th tham s u ra void TestOUTPro() throws Exception{ con= ConnectDBFactory.CreateMsSqlServerConnection(QLSV); String sql={call exOutParams(?,?)};
vovanhai.wordpress.com/java/lp-trinh-java-nang-cao//lam-vic-v i-stored-procedure/ 10/17
12/23/11
CallableStatement cstmt=con.prepareCall(sql); cstmt.setString(1, d%); //ng k tham s u ra cstmt.registerOutParameter(2, java.sql.Types.INTEGER); cstmt.execute(); //Ly gi tr tr v int s=cstmt.getInt(2); System.out.println(s); con.close(); } //Th tham s va vo va ra void TestINOUTPro() throws Exception{ con=ConnectDBFactory.CreateMsSqlServerConnection(QLSV); String sql={call exINOUTParams(?)}; CallableStatement cstmt=con.prepareCall(sql); cstmt.setInt(1, 200); //ng k tham s u ra cstmt.registerOutParameter(1, java.sql.Types.INTEGER); cstmt.execute(); //ly gi tr tr v int s=cstmt.getInt(1); System.out.println(s); con.close(); } //Th vic triu gi 1 function c gi tr tr v public void TestFunctionCall() throws Exception { ConnectDBFactory.CreateMsSqlServerConnection(QLSV); CallableStatement cst=con.prepareCall({?=call getNoStudents(?)}); cst.registerOutParameter(1,java.sql.Types.INTEGER); cst.setString(2,CD);
vovanhai.wordpress.com/java/lp-trinh-java-nang-cao//lam-vic-v i-stored-procedure/ 11/17
12/23/11
sundud said
October 26, 2009 at 2:02 am
Cho em hi lm sao insert mt chui ting vit c du vo mysql thng qua store procedure c gi t java? V em ch lm insert c ting vit vo mysql thng qua cc cu lnh trong mysql query browser thi, cn khi cho gi t java th li khng c. Mong thy ch gip. Em cm n.
vovanhai.wordpress.com/java/lp-trinh-java-nang-cao//lam-vic-v i-stored-procedure/ 12/17
12/23/11
5.
Cho em hi lm sao insert mt chui ting vit c du vo SQL SERVER 2000 thng qua store procedure c gi t form VB.NET V em ch lm insert c ting vit vo SQL thng qua cc cu lnh trong SQL thi bang cch insert values (NNguyn Vn To)nhng thay Nguyn Vn To bng 1 bin cha gi tr ting vit truyn t form VB.NET th li khng c. Mong thy ch gip. Em cm n. 6.
vovanhai said
December 11, 2009 at 6:43 am
Khi ti lm thy bnh thng m. Bn dng VB.Net phin bn no? Khi bn code, design bn c lu form/code ca bn dng unicode khng? 7.
tuyethai said
March 31, 2010 at 6:31 pm
Em chao Thay, Em cung su dung nhung doan code nhu thay vua viet nhung khong hieu sao khong ra duoc. Rat mong thay giup em. Em dung 1 sp voi noi dung nhu sau: CREATE PROCEDURE [dbo].[sp_dsNhanVien] @viTri int, @soMauTin int output AS declare contro scroll cursor for select maNV, ho, ten, ngaySinh, diaChi, luong, ghiChu from NhanVien open contro if(@viTri = 1) begin fetch first from contro end set @soMauTin = @@cursor_rows close contro deallocate contro GO Sp nay em goi trong Analyzer thi nhan duoc output nhung khi viet code java (dung netbean 6.5) thi khong nhan duoc gia tri bien output luon bang 0. try { Class.forName(sun.jdbc.odbc.JdbcOdbcDriver); con = DriverManager.getConnection(jdbc:odbc:QuanLyVatTu, sa, );
vovanhai.wordpress.com/java/lp-trinh-java-nang-cao//lam-vic-v i-stored-procedure/ 13/17
12/23/11
} catch (SQLException ex) { Logger.getLogger(NhanVien.class.getName()).log(Level.SEVERE, null, ex); } catch (ClassNotFoundException ex) { Logger.getLogger(NhanVien.class.getName()).log(Level.SEVERE, null, ex); } try { // TODO add your handling code here: viTri = 1; st = {call sp_dsNhanVien(?, ?)}; cs = con.prepareCall(st); cs.setInt(1, viTri); cs.registerOutParameter(2, java.sql.Types.INTEGER); rs = cs.executeQuery(); soMauTin = cs.getInt(2); // soMauTin: la output va em luon nhan duoc la 0 int j = 0; } catch (SQLException ex) { Logger.getLogger(NhanVien.class.getName()).log(Level.SEVERE, null, ex); } Xin Thay giup em. Em cam on Thay nhieu! 8.
xin hi thy java c gi tr c tip store procedure ca sql server k ah? said
August 12, 2010 at 2:49 am
xin hi thy java c gi trc tip store procedure ca sql server k ah? Nu c th phi lm th no? Mong thy by cch gip e! E xin cm n! 9.
vovanhai said
August 13, 2010 at 3:29 am
Em xem trong phn cc bi vit v JDBC trong blog ny, c ch cch! 10.
vovanhai.wordpress.com/java/lp-trinh-java-nang-cao//lam-vic-v i-stored-procedure/
14/17
12/23/11
11.
vovanhai said
August 21, 2010 at 5:00 am
Tm cc bi trc c. 13.
em dng store proc chn d liu vo db. nhng khng chn c ting vit c du. n b {ting->ti?ng}. mong thy gip . Cm n!. 14.
V Vn Hi said
October 8, 2010 at 3:23 am
Hunh Vn Lc said
October 28, 2010 at 11:13 am
Thy i cho em hi l khi em nhn 1 Resultset tr v t 1 Procedure (param kiu OUT) th n c th Scroll ti lui c khng Thyem dng CSDL Oracle. CallableStatement cs = conn.prepareCall({call GET_LIST_DOMAIN_PROC(?)},ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); cs.registerOutParameter(1,OracleTypes.CURSOR ); cs.execute(); ResultSet rs = (ResultSet)cs.getObject(1);
vovanhai.wordpress.com/java/lp-trinh-java-nang-cao//lam-vic-v i-stored-procedure/ 15/17
12/23/11
V Vn Hi said
November 27, 2010 at 11:44 am
huynhdam39 said
June 30, 2011 at 3:55 pm
xin cm on tc gi 18.
thay oi cho em hoi thay co biet cach nao de load tat ca cac database trong sql server 2005 len combobox trong C# ko thay . Neu thay biet thi giup em voi nha . mail cua em la : thao1412003@yahoo.com cam on thay nhiu lam ^ ^ 19.
em con mot van de nua la neu tren form minh thuc thi store trong sql rui va muon no hien thi ra textbox .vi khi thuc thi store no se cho ra mot cau lenh thuc thi khac dang print trong sql em muon no hien thi phan print do ra ben ngoai form de dung chuoi print do tiep tuc thuc thi cau lenh sql. neu thay biet thi gui mail cho em voi cam on thay nhiu lam ^^ 20.
V Vn Hi said
October 13, 2011 at 3:13 pm
12/23/11
Em cho thy, tha thy em ang lm bi tp m phng ng dng ca DNS bng java m em ang b ri tr v vn nn thc hin th no, mong thy cho em li khuyn . Em chn thnh cm n thy.
Leave a Repl
Enter your comment here...
Fill in your details below or click an icon to log in: ardtimeit@gmail.com Th o Website
Post Comment
17/17