私はLinux ubuntuとモノラルランタイムを初めて使用します。通常、Windowsで行うようにOracle 11Gに接続しようとしました (System.Data.OracleClientとOracle.OracleClientの両方でWindowsで試してみましたが、両方とも正常に機能しました) が、ubuntuでこの問題が発生します: System.DllNotFoundException: libclntsh.so およびこれはスタック トレースです:
libclntsh.so
Description: HTTP 500. Error processing request.
Stack Trace:
System.DllNotFoundException: libclntsh.so
at (wrapper managed-to-native) System.Data.OracleClient.Oci.OciCalls/OciNativeCalls:OCIEnvCreate (intptr&,System.Data.OracleClient.Oci.OciEnvironmentMode,intptr,intptr,intptr,intptr,int,intptr)
at System.Data.OracleClient.Oci.OciCalls.OCIEnvCreate (System.IntPtr& envhpp, OciEnvironmentMode mode, IntPtr ctxp, IntPtr malocfp, IntPtr ralocfp, IntPtr mfreep, Int32 xtramem_sz, IntPtr usrmempp) [0x00000] in <filename unknown>:0
at System.Data.OracleClient.Oci.OciEnvironmentHandle..ctor (OciEnvironmentMode mode) [0x00000] in <filename unknown>:0
at System.Data.OracleClient.Oci.OciGlue.CreateConnection (OracleConnectionInfo conInfo) [0x00000] in <filename unknown>:0
at System.Data.OracleClient.OracleConnectionPoolManager.CreateConnection (OracleConnectionInfo info) [0x00000] in <filename unknown>:0
at System.Data.OracleClient.OracleConnectionPool.CreateConnection () [0x00000] in <filename unknown>:0
at System.Data.OracleClient.OracleConnectionPool.GetConnection () [0x00000] in <filename unknown>:0
at System.Data.OracleClient.OracleConnection.Open () [0x00000] in <filename unknown>:0
at example.Default.button1Clicked (System.Object sender, System.EventArgs args) [0x0000d] in /home/danar/Projects/example/example/Default.aspx.cs:18
at System.Web.UI.WebControls.Button.OnClick (System.EventArgs e) [0x00000] in <filename unknown>:0
at System.Web.UI.WebControls.Button.RaisePostBackEvent (System.String eventArgument) [0x00000] in <filename unknown>:0
at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent (System.String eventArgument) [0x00000] in <filename unknown>:0
at System.Web.UI.Page.RaisePostBackEvent (IPostBackEventHandler sourceControl, System.String eventArgument) [0x00000] in <filename unknown>:0
at System.Web.UI.Page.RaisePostBackEvents () [0x00000] in <filename unknown>:0
at System.Web.UI.Page.ProcessRaiseEvents () [0x00000] in <filename unknown>:0
at System.Web.UI.Page.InternalProcessRequest () [0x00000] in <filename unknown>:0
at System.Web.UI.Page.ProcessRequest (System.Web.HttpContext context) [0x00000] in <filename unknown>:0
そして、これはOracleへの接続文字列で、System.data.oracleclientを使用しました
string oradb = "Data Source=(DESCRIPTION="
+ "(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))"
+ "(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));"
+ "User Id=hr;Password=hr;";
OracleConnection conn = new OracleConnection(oradb);
conn.Open();
OracleCommand command=new OracleCommand();
command.Connection=conn;
command.CommandText="select * from employee";
OracleDataReader reader=command.ExecuteReader();
while(reader.Read())
{
Response.Write(reader[0]+"<br>");
}
conn.Close();
command=null;
reader.Close();
reader=null;