During creating Polygon it throws execution. I am using library Microsoft.SqlServer.Types latest version 160.
polyText = "POLYGON ((
45.3972179 8.8406638000000157,
45.4215054 8.9151509000000715,
45.4001544 8.9361126999999669,
45.4016369 8.9607184999999845,
45.3851877 8.9621395000000348,
45.3853039 8.948319999999967,
45.3747296 8.9535720999999739,
45.3858019 8.9360727000000679,
45.3579525 8.8890794000000142,
45.3414371 8.90664240000001,
45.3452409 8.91328980000003,
45.3273192 8.92622259999996,
45.3185438 8.9208002999999962,
45.3405949 8.8954118000000335,
45.3471543 8.866777299999967,
45.3587372 8.8690788999999768,
45.3675493 8.8504374999999982,
45.3972179 8.8406638000000157,
45.3972179 8.8406638000000157,
45.3972179 8.8406638000000157
))
"
SqlGeography poly = SqlGeography.STGeomFromText(new SqlChars(polyText), 4326);
Exception statk
SQL Server Spatial library could not be loaded. Error code: 126 (HResult: 0x80131524).
Microsoft.SqlServer.Types
System.IO.FileNotFoundException: SQL Server Spatial library could not be loaded. Error code: 126 (HResult: 0x80131524).
at Microsoft.SqlServer.Types.GLNativeMethods.ThowIfGLNativeLibraryNotLoaded()
at Microsoft.SqlServer.Types.GLNativeMethods.GeodeticIsValid(GeoData& g, Double eccentricity, Boolean forceKatmai)
at Microsoft.SqlServer.Types.SqlGeography.IsValidExpensive(Boolean forceKatmai)
at Microsoft.SqlServer.Types.SqlGeography..ctor(GeoData g, Int32 srid)
at Microsoft.SqlServer.Types.SqlGeography.GeographyFromText(OpenGisType type, SqlChars taggedText, Int32 srid)
at Microsoft.SqlServer.Types.SqlGeography.STGeomFromText(SqlChars geometryTaggedText, Int32 srid)
at webNet.Area.Default.DrawShapesFromSql(String polyText, String areaName) in C:\Project\webNet\Area\Default.aspx.cs:line 474
at webNet.Area.Default.LoadForm() in C:\Project\webNet\Area\Default.aspx.cs:line 93
Created SqlGeography.Point it works fine without problem, only creating reading inserting polygon due it throws error.
I managed to resolve this exception by downgrading Microsoft.SqlServer.Types to version 14
I use DNN 9.8.0 new install, language (Swiss) German
If I want to delete an app (Gallery App v5) in the Manage Apps in Zone 2 this message comes after entering yes! in the browser:
Had an error talking to the server (status 405).
if you are an advanced user you can learn more about what went wrong - discover how on 2sxc.org/help?tag=debug
Something else about the browser:
Nothing is shown in Safarai 14.0.1 except the table, but there are no apps (empty field)
Sorry, i work with Safari and Mac...
I see the app in Firefox / Windows 10
The DNN log file shows me this:
2020-11-19 09:05:06.755+01:00 [vps74][D:2][T:8][ERROR] DotNetNuke.Services.Exceptions.Exceptions - FriendlyMessage="Fehler: ist zur Zeit nicht verf�gbar." ctrl="ASP.desktopmodules_tosic_sexycontent_view_ascx" exc="System.ArgumentException: Ein Element mit dem gleichen Schl�ssel wurde bereits hinzugef�gt.
bei System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
bei System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
bei ToSic.Sxc.Cms.Publishing.PagePublishingResolverBase.Requirements(Int32 instanceId) in C:\Projects\2sxc\2sxc\Src\Sxc\ToSic.Sxc\Cms\Publishing\PagePublishingResolverBase.cs:Zeile 20.
bei ToSic.Sxc.Cms.Publishing.PagePublishingResolverBase.GetPublishingState(Int32 instanceId) in C:\Projects\2sxc\2sxc\Src\Sxc\ToSic.Sxc\Cms\Publishing\PagePublishingResolverBase.cs:Zeile 33.
bei ToSic.Sxc.Dnn.Run.DnnContext.Create(ISite site, IContainer container, IUser user, IServiceProvider serviceProvider, List`1 overrideParams) in C:\Projects\2sxc\2sxc\Src\Dnn\ToSic.Sxc.Dnn\Dnn\Run\DnnInstanceContext.cs:Zeile 27.
bei ToSic.SexyContent.View.get_Block() in C:\Projects\2sxc\2sxc\Src\Dnn\ToSic.Sxc.Dnn.Main\View.ascx.cs:Zeile 21.
bei ToSic.SexyContent.View.EnsureCmsBlockAndPortalIsReady() in C:\Projects\2sxc\2sxc\Src\Dnn\ToSic.Sxc.Dnn.Main\View.ascx.Errors.cs:Zeile 19.
bei ToSic.SexyContent.View.<Page_Load>b__9_0() in C:\Projects\2sxc\2sxc\Src\Dnn\ToSic.Sxc.Dnn.Main\View.ascx.cs:Zeile 58.
bei ToSic.SexyContent.View.TryCatchAndLogToDnn(Action action, Action`1 timerWrap) in C:\Projects\2sxc\2sxc\Src\Dnn\ToSic.Sxc.Dnn.Main\View.ascx.Errors.cs:Zeile 44."
2020-11-19 17:54:22.986+01:00 [vps74][D:2][T:83][ERROR] DotNetNuke.Data.PetaPoco.PetaPocoHelper - [4] Error executing SQL: ;Exec dbo.AddFolder #0, #1, #2, #3, #4, #5, #6, #7, #8, #9, #10, #11, #12, #13
Verletzung der UNIQUE KEY-Einschr�nkung "IX_FolderPath". Ein doppelter Schl�ssel kann in das dbo.Folders-Objekt nicht eingef�gt werden. Der doppelte Schl�sselwert ist (0, adam/Gallery-Fancybox3/bVPOkkxHBEy4pYRDFHZMiw/).
Die Anweisung wurde beendet.
Nachtrag vom 20.11.2020, nach dem Upgrade auf 2sic 11.10.01
2020-11-20 09:36:56.701+01:00 [vps74][D:3][T:155][ERROR] DotNetNuke.Services.Exceptions.Exceptions - System.ArgumentException: Ein Element mit dem gleichen Schl�ssel wurde bereits hinzugef�gt.
bei System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
bei System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
bei ToSic.Eav.Data.LazyFastAccess.GetRepo(Int32 id) in C:\Projects\2sxc\eav-server\ToSic.Eav.Core\Data\Lists\LazyFastAccess.cs:Zeile 29.
bei ToSic.Eav.Data.LazyEntities.b__18_1(Nullable`1 l) in C:\Projects\2sxc\eav-server\ToSic.Eav.Core\Data\Entities\LazyEntities.cs:Zeile 150.
bei System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
bei System.Collections.Generic.List1..ctor(IEnumerable1 collection)
bei System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
bei ToSic.Eav.Data.LazyEntities.LoadEntities() in C:\Projects\2sxc\eav-server\ToSic.Eav.Core\Data\Entities\LazyEntities.cs:Zeile 143.
bei ToSic.Eav.Data.LazyEntities.GetEnumerator() in C:\Projects\2sxc\eav-server\ToSic.Eav.Core\Data\Entities\LazyEntities.cs:Zeile 132.
bei System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
bei System.Collections.Generic.List1..ctor(IEnumerable1 collection)
bei System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
bei ToSic.Sxc.Data.DynamicEntityWithList..ctor(IEntity parent, String field, IEnumerable`1 entities, String[] dimensions, Int32 compatibility, IBlock block) in C:\Projects\2sxc\2sxc\Src\Sxc\ToSic.Sxc\Data\DynamicEntityWithList.cs:Zeile 28.
bei ToSic.Sxc.Data.DynamicEntity.GetEntityValue(String field) in C:\Projects\2sxc\2sxc\Src\Sxc\ToSic.Sxc\Data\DynamicEntity.cs:Zeile 144.
bei ToSic.Sxc.Data.DynamicEntity.TryGetMember(GetMemberBinder binder, Object& result) in C:\Projects\2sxc\2sxc\Src\Sxc\ToSic.Sxc\Data\DynamicEntity.cs:Zeile 98.
bei CallSite.Target(Closure , CallSite , Object )
bei ASP._Page_Portals_0_2sxc_Swiper__swiper_cshtml.Execute() in d:\WEB\EW-WEB\Portals\0\2sxc\Swiper_swiper.cshtml:Zeile 18.
bei System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
bei System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
bei ToSic.Sxc.Engines.RazorEngine.Render(TextWriter writer) in C:\Projects\2sxc\2sxc\Src\Dnn\ToSic.Sxc.Razor\Engines\Razor\RazorEngine.cs:Zeile 67.
bei ToSic.Sxc.Engines.RazorEngine.RenderTemplate() in C:\Projects\2sxc\2sxc\Src\Dnn\ToSic.Sxc.Razor\Engines\Razor\RazorEngine.cs:Zeile 77.
bei ToSic.Sxc.Engines.EngineBase.Render() in C:\Projects\2sxc\2sxc\Src\Sxc\ToSic.Sxc\Engines\EngineBase.cs:Zeile 148.
bei ToSic.Sxc.Blocks.BlockBuilder.Render() in C:\Projects\2sxc\2sxc\Src\Sxc\ToSic.Sxc\Blocks\BlockBuilder_Render.cs:Zeile 57.
Do I get "answer" credit if my Issue contains the answwer? :)
Cannot Delete Things - API, Extensionless URI handler overridden by WebDAV
Why do I keep seeing this error?
Execution timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
I don't know if the problem is in the server, or in the system itself or in the web service that created. I reconfigure the server to clear the cache memory and run a test but no luck still have that problem.
This is the code where the error is tracing
DialogWaitForm.Show()
BillInfoTableAdapter.Fill(ReportsDataSet.BillInfo, CType(CreateBillingForm.CurrentBillTransactionID, Long))
Dim row As ReportsDataSet.BillInfoRow
row = CType(CType(BillInfoBindingSource.Current, DataRowView).Row, ReportsDataSet.BillInfoRow)
Me.BillingTransactionsTableAdapter.Fill(Me.ReportsDataSet.BillingTransactions, CType(CreateBillingForm.ComboBoxClient.SelectedValue, Long), statementid(), row.BeginDate.Year)
Dim row4 As ReportsDataSet.BillingTransactionsRow
row4 = CType(CType(BillingTransactionsBindingSource.Current, DataRowView).Row, ReportsDataSet.BillingTransactionsRow)
BillingTransactionsBindingSource.MoveFirst()
Me.BillingAIRBILLSPerServiceTableAdapter.Fill(Me.ReportsDataSet.BillingAIRBILLSPerService, row.ID)
Me.BillingCurrentChargesTableAdapter.Fill(Me.ReportsDataSet.BillingCurrentCharges, CType(Client(), Long), CType(_current(), Decimal), CType(_currentyear, Decimal), statementid())
Me._30daysTableAdapter.Fill(Me.ReportsDataSet._30days, CType(Client(), Long), CType(_30(), Decimal), CType(_30year, Decimal), CType(statementid(), Long))
Me._60daysTableAdapter.Fill(Me.ReportsDataSet._60days, CType(Client(), Long), CType(_60(), Decimal), CType(_60year, Decimal), CType(statementid(), Long))
Me._90daysTableAdapter.Fill(Me.ReportsDataSet._90days, CType(Client(), Long), CType(_90(), Decimal), CType(_90year, Decimal), CType(statementid(), Long))
Me._120daysTableAdapter.Fill(Me.ReportsDataSet._120days, CType(Client(), Long), CType(_120(), Decimal), CType(_120year, Decimal), CType(statementid(), Long))
Me.morethan120daysTableAdapter.Fill(Me.ReportsDataSet.morethan120days, CType(Client(), Long), morethan120)
Me.ThisYearPreviousBalanceCrTableAdapter.Fill(Me.ReportsDataSet.ThisYearPreviousBalanceCr, CType(Client(), Long), row4.StatementOrRecptDate.Date)
Me.BillingCurrentCRTableAdapter.Fill(Me.ReportsDataSet.BillingCurrentCR, CType(Client(), Long), CType(_current(), Decimal), CType(_currentyear, Decimal), CType(statementid(), Long))
Me._30daysCRTableAdapter.Fill(Me.ReportsDataSet._30daysCR, CType(Client(), Long), CType(_30(), Decimal), CType(_30year, Decimal), CType(statementid(), Long))
Me._60daysCRTableAdapter.Fill(Me.ReportsDataSet._60daysCR, CType(Client(), Long), CType(_60(), Decimal), CType(_60year, Decimal), CType(statementid(), Long))
Me._90daysCRTableAdapter.Fill(Me.ReportsDataSet._90daysCR, CType(Client(), Long), CType(_90(), Decimal), CType(_90year, Decimal), CType(statementid(), Long))
Me._120daysCRTableAdapter.Fill(Me.ReportsDataSet._120daysCR, CType(Client(), Long), CType(_120(), Decimal), CType(_120year, Decimal), CType(statementid(), Long))
Me.morethan120daysCRTableAdapter.Fill(Me.ReportsDataSet.morethan120daysCR, CType(Client(), Long), morethan120, row.StatementID)
Me.ThisYearPreviousBalanceDrTableAdapter.Fill(Me.ReportsDataSet.ThisYearPreviousBalanceDr, CType(Client(), Long), row4.StatementOrRecptDate)
fillbilltransaction()
If CreateBillingForm.RadioButtonWithPOD.Checked = True Then
filltempWithPOD()
Else
filltempNoPOD()
End If
DialogWaitForm.Dispose()
Me.ReportViewer1.RefreshReport()
now I have this error
The server was unable to process the request due to an internal error.
For more information about the error, either turn on
IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute
or from the configuration behavior) on the server in
order to send the exception information back to the client, or turn on
tracing as per the Microsoft .NET Framework SDK documentation and
inspect the server trace logs.
what happened to my server please help TIA.
this is the stack trace error
System.ServiceModel.FaultException was unhandled
HResult=-2146233087
Message=The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs.
Source=mscorlib
StackTrace:
Server stack trace:
at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at JRS_Online_Apps_III.ServiceReferenceBilling.IService.RequestGenerateBill(String rclid, String ruserid, String rbrid, String rdatefrom, String rdateto, String rduedate, String careof, Int64[] rairbillsids, Decimal rNet, Decimal rRvat, Int32 rstatement, String bir)
at JRS_Online_Apps_III.ServiceReferenceBilling.ServiceClient.RequestGenerateBill(String rclid, String ruserid, String rbrid, String rdatefrom, String rdateto, String rduedate, String careof, Int64[] rairbillsids, Decimal rNet, Decimal rRvat, Int32 rstatement, String bir) in C:\Users\REGIME\Desktop\New folder\JRS_Online_Apps_III\JRS_Online_Apps_III\Service References\ServiceReferenceBilling\Reference.vb:line 254
at JRS_Online_Apps_III.CreateBillingForm.Button1_Click(Object sender, EventArgs e) in C:\Users\REGIME\Desktop\New folder\JRS_Online_Apps_III\JRS_Online_Apps_III\Billing\CreateBillingForm.vb:line 238
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at JRS_Online_Apps_III.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
Updated Code
sqlconnect()
sqltable = New DataTable
sqladapter = New SqlDataAdapter("SELECT * FROM AIRBILLS WHERE AirbillNo = '" & "123456" & "'",sqlcon)
sqladapter.Fill(sqltable)
MsgBox(sqltable.Rows(0)("Addressee"))
this is my error
https://ibb.co/ih3aQG
Your last Sql Select Statement doesn't look ok ... isn't there a "=" sign missing? Like "SELECT * FROM AIRBILLS WHERE AirbillNo = '" & "123456" & "'", ...
Apart from that you should think about using SqlParameters for passing Parameters ...
Npgsql v3.0.0-beta0001 (Prerelease) was having below issue while opening connection.
NpgsqlConnection conn = new NpgsqlConnection(#"Server=xx.xx.xx.xx;Port=9996;Database=xxx;User Id=xx;Password=xx;CommandTimeout=40;");
conn.Open();
ex {" : View 'pg_type' not found"} System.Exception {Npgsql.NpgsqlException}
StackTrace " at Npgsql.NpgsqlConnector.DoReadSingleMessage(DataRowLoadingMode dataRowLoadingMode, Boolean returnNullForAsyncMessage)\r\n at Npgsql.NpgsqlConnector.ReadSingleMessage(DataRowLoadingMode dataRowLoadingMode, Boolean returnNullForAsyncMessage)\r\n at Npgsql.NpgsqlConnector.SkipUntil(BackendMessageCode stopAt1, BackendMessageCode stopAt2)\r\n at Npgsql.NpgsqlDataReader.SkipUntil(BackendMessageCode stopAt1, BackendMessageCode stopAt2)\r\n at Npgsql.NpgsqlDataReader.NextResultInternal()\r\n at Npgsql.NpgsqlDataReader.NextResult()\r\n at Npgsql.NpgsqlDataReader.Init()\r\n at Npgsql.NpgsqlCommand.Execute(CommandBehavior behavior)\r\n at Npgsql.NpgsqlCommand.ExecuteDbDataReaderInternal(CommandBehavior behavior)\r\n at Npgsql.NpgsqlCommand.ExecuteDbDataReader(CommandBehavior behavior)\r\n at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)\r\n at Npgsql.NpgsqlCommand.ExecuteReader(CommandBehavior behavior)\r\n at Npgsql.TypeHandlerRegistry.LoadBackendTypes(NpgsqlConnector connector)\r\n at Npgsql.TypeHandlerRegistry.Setup(NpgsqlConnector connector)\r\n at Npgsql.NpgsqlConnector.Open()\r\n at Npgsql.NpgsqlConnectorPool.GetPooledConnector(NpgsqlConnection Connection)\r\n at Npgsql.NpgsqlConnectorPool.RequestConnector(NpgsqlConnection connection)\r\n at Npgsql.NpgsqlConnection.Open()\r\n at Test.Program.MssDenodoUpdate(String ssConnectionName, String ssTableName, TestDenodoUpdate ssUpdateRecord, String ssWhereClause, Int32 ssTimeout, Int32& ssUpdatedRows) in d:\EMRP\EMRP\DenodoConnector\Source\ConsoleApplication2\Program.cs:line 66" string
EntityFramework needs a "maintenance" DB in order to create databases, etc.
Before npgsql version 2.2.5. this maintenance DB was "postgres" but, since then this maintenance DB is "template1", which exists on all PostgreSQL versions.
To make EF work with Denodo you have to create in VDP the dummy database called template1.
Hope this helps!
Virtual DataPort is compatible with the .Net Data Provider for PostgreSQL version 2.0. The recommended versions are 2.0.12, 2.2.0, 2.2.3 and 2.2.7 .
I used .netframework 4.5, npgsql version 2.2.0
string query = "SELECT * FROM car";
string connectionString = "Server=localhost;Port=9996;Username=admin;Password=admin;Database=admin;Timeout=300;CommandTimeout=300";
try
{
using (NpgsqlConnection connection = new NpgsqlConnection(connectionString))
{
connection.Open();
using (NpgsqlCommand command = new NpgsqlCommand(query, connection))
{
using (DbDataReader reader = command.ExecuteReader())
{
int readRows = 0;
Console.WriteLine();
Console.WriteLine("RESULTS:");
while (reader.Read() && readRows < maxRows)
{
for (int col = 0; col < reader.FieldCount; col++)
{
Console.Write(reader.GetName(col) + "=" + reader[col]);
Console.Write(" ");
}
Console.WriteLine();
readRows++;
}
}
}
}
}
I'm converting some jdbc code from MySql to SQL Server. When trying to
query = "Update ReportSetup "
+ "set N_ID=?, "
+ "R_Default=?, "
+ "R_Name=?, "
+ "R_Module=? "
+ " where R_ID = ?";
}
PreparedStatement stmt =
(PreparedStatement) con.prepareStatement(query, Statement.RETURN_GENERATED_KEYS);
stmt.setInt(1, ri.getNodeID());
stmt.setInt(2, (ri.isDefault()) ? 1 : 0);
stmt.setString(3, ri.getName());
Object o = ri.getReportModule();
stmt.setObject(4, o);
The last statement stmt.setObject(4,o) throws the exception.
ri.getReportModule returns an instance of a class which implements Externalizable.
The method writeExternal() of that class is implemented as
public final void writeExternal(final ObjectOutput objectOutput) throws IOException {
for (int i=0; i<pdV.size(); i++) {
PropertyDescriptor pd = pdV.elementAt(i);
try {
Method m = pd.getReadMethod();
Object val = pd.getReadMethod().invoke(this);
System.out.print("writing property " + i + ": " + pd.getName() + " = " + val);
objectOutput.writeObject(val);
} catch (Exception e) {
e.printStackTrace();
}
}
}
The database column in question is defined as
varbinary(max), not null
The code works well using MySql but I can't figure out what to do to make it run with Sql Server.
Any suggestions would be very much appreciated
The problem was that sql server is not happy to save a serialization (as done when implementing externalizable). .setObject() fails. The solution is to use setBinaryStream().
// Sql Server can't do an stmt.setObject(4,o) "Conversion from UNKNOWN to UNKNOWN not supported"
// Serialize the object to an output stream and then read it in again into the stmt.
Object o = ri.getReportModule();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream objectOutput = new ObjectOutputStream(bos);
objectOutput.writeObject(o);
objectOutput.flush();
InputStream objectInput = new ByteArrayInputStream(bos.toByteArray());
stmt.setBinaryStream(4, objectInput);
Cheers
Christian