mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
added sqllite
This commit is contained in:
@@ -30,7 +30,7 @@ void WinDatabase::connect()
|
||||
rc = SQLAllocHandle(SQL_HANDLE_DBC,henv, &hdbc);
|
||||
myenv(henv, rc);
|
||||
|
||||
rc = SQLConnect(hdbc, (unsigned char*)(char*) mHost, SQL_NTS, (unsigned char*)(char*) mUser, SQL_NTS, (unsigned char*)(char*) mDBPass, SQL_NTS);
|
||||
rc = SQLConnect(hdbc, (unsigned char*)(char*) mHost.c_str(), SQL_NTS, (unsigned char*)(char*) mUser.c_str(), SQL_NTS, (unsigned char*)(char*) mDBPass.c_str(), SQL_NTS);
|
||||
mycon(hdbc, rc);
|
||||
|
||||
rc = SQLSetConnectAttr(hdbc,SQL_ATTR_AUTOCOMMIT,(SQLPOINTER)SQL_AUTOCOMMIT_ON,0);
|
||||
@@ -42,7 +42,7 @@ void WinDatabase::connect()
|
||||
//rc = SQLGetInfo(hdbc,SQL_DBMS_NAME,&server_name,40,NULL);
|
||||
//mycon(hdbc, rc);
|
||||
|
||||
theUI->statusMsg("Connection Established to DB");
|
||||
//theUI->statusMsg("Connection Established to DB");
|
||||
}
|
||||
|
||||
void WinDatabase::disconnect()
|
||||
@@ -76,7 +76,7 @@ bool WinDatabase::executeSQL(const char* sql)
|
||||
SQLRETURN rc = SQLExecDirect(hstmt,(unsigned char*) sql,SQL_NTS);
|
||||
if(rc==SQL_ERROR)
|
||||
{
|
||||
theUI->errorMsg("Trying to recover from DB error");
|
||||
//theUI->errorMsg("Trying to recover from DB error");
|
||||
rc = SQLExecDirect(hstmt,(unsigned char*) sql,SQL_NTS);
|
||||
if(rc==SQL_ERROR)
|
||||
{
|
||||
@@ -88,7 +88,7 @@ bool WinDatabase::executeSQL(const char* sql)
|
||||
i = 1;
|
||||
while ((rc2 = SQLGetDiagRec(SQL_HANDLE_STMT, hstmt, i, SqlState, &NativeError, Msg, sizeof(Msg), &MsgLen)) != SQL_NO_DATA)
|
||||
{
|
||||
theUI->errorMsg("DB ERROR: %s,%d,%s",SqlState,NativeError,Msg);
|
||||
//theUI->errorMsg("DB ERROR: %s,%d,%s",SqlState,NativeError,Msg);
|
||||
i++;
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ bool WinDatabase::getNextRow()
|
||||
|
||||
|
||||
|
||||
char* WinDatabase::getStr(int colIndex,i4_str* retStr)
|
||||
char* WinDatabase::getStr(int colIndex,string& retStr)
|
||||
{
|
||||
colIndex++;
|
||||
(*retStr)="";
|
||||
@@ -169,7 +169,7 @@ char* WinDatabase::getStr(int colIndex,i4_str* retStr)
|
||||
return(*retStr);
|
||||
}
|
||||
|
||||
w32 WinDatabase::getInt(int colIndex)
|
||||
int32 WinDatabase::getInt(int colIndex)
|
||||
{
|
||||
colIndex++;
|
||||
int ret=0;
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include "sql.h"
|
||||
#endif
|
||||
|
||||
#include "string/i4string.h"
|
||||
|
||||
/*
|
||||
this maintains the connection to the database
|
||||
@@ -28,12 +27,13 @@ public:
|
||||
void connect();
|
||||
void disconnect();
|
||||
|
||||
char* getPass(){ return(mDBPass); }
|
||||
//char* getPass(){ return((char*)mDBPass.c_str()); }
|
||||
|
||||
// returns true if the query went ok
|
||||
bool executeSQL(const char* sql);
|
||||
|
||||
int getNumRowsAffected();
|
||||
int getLastInsertID();
|
||||
|
||||
// returns false if there are no results
|
||||
bool startIterRows();
|
||||
@@ -44,10 +44,14 @@ public:
|
||||
bool getNextRow();
|
||||
|
||||
// get Data from the current row
|
||||
char* getStr(int colIndex,i4_str* retStr);
|
||||
w32 getInt(int colIndex);
|
||||
char* getStr(int colIndex,std::string& retStr);
|
||||
int32 getInt(int colIndex);
|
||||
float getFloat(int colIndex);
|
||||
bool getBool(int colIndex);
|
||||
uint64 getBigInt(int colIndex);
|
||||
bool getBinary(int colIndex,unsigned char* buf,int maxSize);
|
||||
|
||||
void escape(unsigned char* start,int size,std::string& retStr);
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user