MYSQL ¿¡¼´Â import com.mysql.jdbc.PreparedStatement; ÇÑ µÚ
PreparedStatement ps = (PreparedStatement) conn.prepareStatement("SELECT modelname FROM manage WHERE modelname LIKE CONCAT('%', ?, '%')");
ps.setString(1, tfSearch.getText());
ResultSet rs = ps.executeQuery(); ÀÌ·±½ÄÀ¸·Î ¼º°øÇß½À´Ï´Ù..
DB¸¦ ¹Ù²ã¾ßÇÏ´Â »óȲÀÌ¾î¼ SQL SERVER 2008·Î ¿¬µ¿À» ÇÏ¿´½À´Ï´Ù.
MSSQL¿¡¼´Â ¾î¶²½ÄÀ¸·Î ¼Ò½ºÃ³¸®¸¦ ÇؾßÇÒÁö µµÀúÈ÷ °¨ÀÌ ¾ÈÀâÈ÷³×¿ä ..
±×¸®°í º¯¼ö´Â || ** || ÀÌ·±½ÄÀ¸·Î ¹Þ¾Æ¾ßÇϳª¿ä?
=> tfSearch¸¦ ÅëÇؼ ÀԷ¹ÞÀº Äõ¸®¸¦ Á¶È¸ÇÏ·Á°í ÇÕ´Ï´Ù.. µµ¿ÍÁÖ¼¼¿ä | |
|
Äõ¸®´Â Á¤»óÀÌ°í
ps, rsµµ mssql·Î ÀÓÆ÷Æ®ÇßÀ¸¸é Á¤»óÀÔ´Ï´Ù
import com.microsoft.sqlserver.jdbc.SQLServerConnection;
import com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement;
import com.microsoft.sqlserver.jdbc.SQLServerResultSet;
ÀÌ°ÅÇßÀ¸¸é ¿À·ù°¡ ÀÌÀü±ÛÀ̶ûÀº ´Ù¸£°Ô ³ª¿Ã°Å°°Àºµ¥ ¿À·ù¸¦ ¿Ã·ÁÁÖ¼¼¿ä
mssql·Î ÀÓÆ÷Æ® ÇÏ¸é¼ import com.microsoft.*; ¿Í import com.ibatis.sqlmap.*; ¸¦ Ãß°¡Çß½À´Ï´Ù.
PreparedStatement ÆĶó¹ÌÅÍ ¿À·ùÀΰŰ°Àºµ¥ ¿À·ùµµ ÷ºÎÇÏ°Ú½À´Ï´Ù..
--------------------------
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement cannot be cast to com.mysql.jdbc.PreparedStatement
at JTableExample.actionPerformed(JTableExample.java:134)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$300(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)