我这段代码实现插入数据,但会抛出 "can't found free connection" 的异常,一直找不到解决的办法啊``
希望高手指点出错误所在!谢谢`#define INSERTSQL "insert into SystemTab(TableId,Key1,Key2,Key3,Key4) values(?,?,?,?,?)"
void SystemTabManager::insert(int pkey1, int TabId)
{
DBConnection* conn=NULL;
SystemTab* pSystemTab=NULL;
try
{
SystemTab::TABLE temp;
temp.key.Key1=pkey1;
temp.key.TableId=TabId;
temp.Key2=1;
conn=&(DBConnectionFactory::getIntance()->getConnection());
Statement& stmt=conn->createDyncStatement(INSERTSQL);
int pos=0;
stmt.setParam(pos++, temp.key.TableId);
stmt.setParam(pos++, temp.key.Key1);
stmt.setParam(pos++, temp.Key2);
stmt.execute();
SystemTab::TABLE tabsystemtab=temp;
tabsystemtab.key.Key1=temp.key.Key1;
pSystemTab=new SystemTabImpl(tabsystemtab);
conn->close();
}
catch (DatabaseException e)
{
if(conn)
conn->close();
}}
希望高手指点出错误所在!谢谢`#define INSERTSQL "insert into SystemTab(TableId,Key1,Key2,Key3,Key4) values(?,?,?,?,?)"
void SystemTabManager::insert(int pkey1, int TabId)
{
DBConnection* conn=NULL;
SystemTab* pSystemTab=NULL;
try
{
SystemTab::TABLE temp;
temp.key.Key1=pkey1;
temp.key.TableId=TabId;
temp.Key2=1;
conn=&(DBConnectionFactory::getIntance()->getConnection());
Statement& stmt=conn->createDyncStatement(INSERTSQL);
int pos=0;
stmt.setParam(pos++, temp.key.TableId);
stmt.setParam(pos++, temp.key.Key1);
stmt.setParam(pos++, temp.Key2);
stmt.execute();
SystemTab::TABLE tabsystemtab=temp;
tabsystemtab.key.Key1=temp.key.Key1;
pSystemTab=new SystemTabImpl(tabsystemtab);
conn->close();
}
catch (DatabaseException e)
{
if(conn)
conn->close();
}}
又抛出异常:exception {_m_what=0x076c0968 "INSERT INTO 语句的语法错误。" _m_doFree=1 }我仔细检查了插入语句(#define INSERTSQL "insert into SystemTab(TableId,Key1,Key2,Key3,Key4) values(?,?,?,?,?)"
)应该没有语法错误啊!我想问问各位高手还有什么其他原因影响了插入语法?
应该是关键字的问题!
我结贴了!!
再次祝福楼上各位大大 牛年走大运 牛气冲天