Explain the output of the program?
In this program I want to use the access specifier inside the method so is
it possible
class AccessTest{
int i;
public static void main (String... str)
{
int i;
private int a = 1;
protected int b = 1;
public int c = 1;
System.out.print (a+b+c);
}
}
what is the final output can anybody explain this ?
Monday, 2 September 2013
[FireDac][Phys][MySQL]-11011. Unsupported MySQL version [0] Delphi
[FireDac][Phys][MySQL]-11011. Unsupported MySQL version [0] Delphi
Hello im having a bit of a problem. I have successfully created a form to
be deployed from a dll. So i said to my self why not try to add database
connectivity within the DLL. I went and read the documentation for DLL
http://docs.embarcadero.com/products/rad_studio/firedac/DLL_Development.html
tried the demo and it worked so i converted the demo to a mysql demo to
see if it would work. When i try calling the Dll with the main application
form Project1.exe it showed this error
[FireDac][Phys][MySQL]-11011. Unsupported MySQL version [0]. Supported are
client and server from v 3.20 to v6.2.
But the funny thing is im using the same librarys i used to connect the
Main Application to my mysql server which uses the same components.
Basically the Application shares a connection with the dll form in which i
thought in theory it would work. Please Help me solve this here is the
code below. Please tell me if im doing anything wrong.
Main Application- Project1.exe
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, uADStanIntf, uADStanOption, uADStanDef, uADPhysIntf,
uADDatSManager, uADStanParam, uADDAptIntf, StdCtrls, Grids, DBGrids,
DB, uADPhysManager, uADPhysMSAcc, uADGUIxFormsWait, uADCompGUIx,
uADCompDataSet,
uADCompClient, uADStanError, uADGUIxIntf, uADStanPool, uADStanAsync,
uADDAptManager, uADPhysODBCBase, uADGUIxFMXWait, uADPhysMySQL;
type
TShowDataProc = procedure (ACliHandle: Pointer); stdcall;
TShutdownProc = procedure; stdcall;
TForm1 = class(TForm)
ADConnection1: TADConnection;
ADQuery1: TADQuery;
ADGUIxWaitCursor1: TADGUIxWaitCursor;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
Button1: TButton;
Button2: TButton;
Button3: TButton;
ADPhysMySQLDriverLink1: TADPhysMySQLDriverLink;
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
FhDll: THandle;
FpShowData: TShowDataProc;
FpShutdown: TShutdownProc;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses
uADStanUtil;
procedure TForm1.Button1Click(Sender: TObject);
begin
FhDll := LoadLibrary(PChar('Project2.dll'));
if FhDll = 0 then
raise Exception.Create(ADLastSystemErrorMsg);
@FpShowData := GetProcAddress(FhDll, PChar('ShowData'));
if not Assigned(FpShowData) then
raise Exception.Create(ADLastSystemErrorMsg);
@FpShutdown := GetProcAddress(FhDll, PChar('Shutdown'));
if not Assigned(FpShutdown) then
raise Exception.Create(ADLastSystemErrorMsg);
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
FpShowData(ADConnection1.CliHandle);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
FpShutdown();
FreeLibrary(FhDll);
FhDll := 0;
@FpShowData := nil;
@FpShutdown := nil;
end;
end.
Dll library Project2.dll
library Project2;
{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }
uses
SysUtils,
Classes,
Forms,
uADCompClient,
uADStanFactory,
Unit2 in 'Unit2.pas' {Form2};
{$R *.res}
procedure ShowData(ACliHandle: Pointer); stdcall;
begin
TForm2.ShowData(ACliHandle);
end;
procedure Shutdown; stdcall;
var
i: Integer;
begin
for i := Application.ComponentCount - 1 downto 0 do
if Application.Components[i] is TForm then
Application.Components[i].Free;
ADTerminate;
end;
exports
ShowData,
Shutdown;
begin
end.
Unit2- The form in the Dll
This has a query that does a simple select all from the suppliers database
in the firedac demo datbase
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, uADStanIntf, uADStanOption, uADStanDef, uADPhysIntf,
uADDatSManager, uADStanParam, uADDAptIntf, Grids, DBGrids, DB,
uADPhysManager, uADPhysMSAcc, uADGUIxFormsWait, uADCompGUIx,
uADCompDataSet,
uADCompClient, uADStanError, uADGUIxIntf, uADStanPool, uADStanAsync,
uADDAptManager, uADPhysODBCBase, uADGUIxFMXWait, uADPhysMySQL;
type
TForm2 = class(TForm)
ADConnection1: TADConnection;
ADQuery1: TADQuery;
ADGUIxWaitCursor1: TADGUIxWaitCursor;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
ADPhysMySQLDriverLink1: TADPhysMySQLDriverLink;
public
class procedure ShowData(ACliHandle: Pointer);
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
{ TForm2 }
class procedure TForm2.ShowData(ACliHandle: Pointer);
var
oForm: TForm2;
begin
oForm := TForm2.Create(Application);
oForm.ADConnection1.SharedCliHandle := ACliHandle;
oForm.ADConnection1.Connected := True;
oForm.ADQuery1.Active := True;
oForm.Show;
end;
end.
Hello im having a bit of a problem. I have successfully created a form to
be deployed from a dll. So i said to my self why not try to add database
connectivity within the DLL. I went and read the documentation for DLL
http://docs.embarcadero.com/products/rad_studio/firedac/DLL_Development.html
tried the demo and it worked so i converted the demo to a mysql demo to
see if it would work. When i try calling the Dll with the main application
form Project1.exe it showed this error
[FireDac][Phys][MySQL]-11011. Unsupported MySQL version [0]. Supported are
client and server from v 3.20 to v6.2.
But the funny thing is im using the same librarys i used to connect the
Main Application to my mysql server which uses the same components.
Basically the Application shares a connection with the dll form in which i
thought in theory it would work. Please Help me solve this here is the
code below. Please tell me if im doing anything wrong.
Main Application- Project1.exe
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, uADStanIntf, uADStanOption, uADStanDef, uADPhysIntf,
uADDatSManager, uADStanParam, uADDAptIntf, StdCtrls, Grids, DBGrids,
DB, uADPhysManager, uADPhysMSAcc, uADGUIxFormsWait, uADCompGUIx,
uADCompDataSet,
uADCompClient, uADStanError, uADGUIxIntf, uADStanPool, uADStanAsync,
uADDAptManager, uADPhysODBCBase, uADGUIxFMXWait, uADPhysMySQL;
type
TShowDataProc = procedure (ACliHandle: Pointer); stdcall;
TShutdownProc = procedure; stdcall;
TForm1 = class(TForm)
ADConnection1: TADConnection;
ADQuery1: TADQuery;
ADGUIxWaitCursor1: TADGUIxWaitCursor;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
Button1: TButton;
Button2: TButton;
Button3: TButton;
ADPhysMySQLDriverLink1: TADPhysMySQLDriverLink;
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
FhDll: THandle;
FpShowData: TShowDataProc;
FpShutdown: TShutdownProc;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses
uADStanUtil;
procedure TForm1.Button1Click(Sender: TObject);
begin
FhDll := LoadLibrary(PChar('Project2.dll'));
if FhDll = 0 then
raise Exception.Create(ADLastSystemErrorMsg);
@FpShowData := GetProcAddress(FhDll, PChar('ShowData'));
if not Assigned(FpShowData) then
raise Exception.Create(ADLastSystemErrorMsg);
@FpShutdown := GetProcAddress(FhDll, PChar('Shutdown'));
if not Assigned(FpShutdown) then
raise Exception.Create(ADLastSystemErrorMsg);
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
FpShowData(ADConnection1.CliHandle);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
FpShutdown();
FreeLibrary(FhDll);
FhDll := 0;
@FpShowData := nil;
@FpShutdown := nil;
end;
end.
Dll library Project2.dll
library Project2;
{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }
uses
SysUtils,
Classes,
Forms,
uADCompClient,
uADStanFactory,
Unit2 in 'Unit2.pas' {Form2};
{$R *.res}
procedure ShowData(ACliHandle: Pointer); stdcall;
begin
TForm2.ShowData(ACliHandle);
end;
procedure Shutdown; stdcall;
var
i: Integer;
begin
for i := Application.ComponentCount - 1 downto 0 do
if Application.Components[i] is TForm then
Application.Components[i].Free;
ADTerminate;
end;
exports
ShowData,
Shutdown;
begin
end.
Unit2- The form in the Dll
This has a query that does a simple select all from the suppliers database
in the firedac demo datbase
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, uADStanIntf, uADStanOption, uADStanDef, uADPhysIntf,
uADDatSManager, uADStanParam, uADDAptIntf, Grids, DBGrids, DB,
uADPhysManager, uADPhysMSAcc, uADGUIxFormsWait, uADCompGUIx,
uADCompDataSet,
uADCompClient, uADStanError, uADGUIxIntf, uADStanPool, uADStanAsync,
uADDAptManager, uADPhysODBCBase, uADGUIxFMXWait, uADPhysMySQL;
type
TForm2 = class(TForm)
ADConnection1: TADConnection;
ADQuery1: TADQuery;
ADGUIxWaitCursor1: TADGUIxWaitCursor;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
ADPhysMySQLDriverLink1: TADPhysMySQLDriverLink;
public
class procedure ShowData(ACliHandle: Pointer);
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
{ TForm2 }
class procedure TForm2.ShowData(ACliHandle: Pointer);
var
oForm: TForm2;
begin
oForm := TForm2.Create(Application);
oForm.ADConnection1.SharedCliHandle := ACliHandle;
oForm.ADConnection1.Connected := True;
oForm.ADQuery1.Active := True;
oForm.Show;
end;
end.
Change state of interface value in Go (language)
Change state of interface value in Go (language)
Is it possible to change the state of a struct that implements an interface?
Here's what I mean: consider an interface IWidget with a method foo(), and
a struct Widget. Can a call to foo() update the state of the original
instance I assigned to the interface?
An example, where the state is n int:
package main
import "fmt"
type IWidget interface {
foo()
}
type Widget struct {
n int
}
func (this Widget) foo(){
this.n++
fmt.Println("foo:", this.n)
}
func main() {
myWidget := Widget{5}
var iface IWidget = &myWidget
iface.foo() // 6
iface.foo() // still 6, because the receiver is passed by value
// and the original wasn't affected by the first call
fmt.Println(myWidget) // 5, the original
myWidget.n--
fmt.Println(myWidget) // 4, of course
myWidget.n--
fmt.Println(myWidget) // 3, of course
iface.foo() // 4, i.e. 3+1: the interface is referencing the original
// because I assigned &myWidget, not myWidget
}
OK, so changes made directly on the original can be seen in the interface
value if I assign a pointer. But I still don't see how I can change the
state of the original (or even a copy) from within foo(), all the more so
because (as far as I understand) I am not allowed to declare a receiver
(this *Widget).
Is it possible to change the state of a struct that implements an interface?
Here's what I mean: consider an interface IWidget with a method foo(), and
a struct Widget. Can a call to foo() update the state of the original
instance I assigned to the interface?
An example, where the state is n int:
package main
import "fmt"
type IWidget interface {
foo()
}
type Widget struct {
n int
}
func (this Widget) foo(){
this.n++
fmt.Println("foo:", this.n)
}
func main() {
myWidget := Widget{5}
var iface IWidget = &myWidget
iface.foo() // 6
iface.foo() // still 6, because the receiver is passed by value
// and the original wasn't affected by the first call
fmt.Println(myWidget) // 5, the original
myWidget.n--
fmt.Println(myWidget) // 4, of course
myWidget.n--
fmt.Println(myWidget) // 3, of course
iface.foo() // 4, i.e. 3+1: the interface is referencing the original
// because I assigned &myWidget, not myWidget
}
OK, so changes made directly on the original can be seen in the interface
value if I assign a pointer. But I still don't see how I can change the
state of the original (or even a copy) from within foo(), all the more so
because (as far as I understand) I am not allowed to declare a receiver
(this *Widget).
CanJS models with Knockout
CanJS models with Knockout
I have a medium size single page application using Knockout that I would
like to port incrementally to CanJS. The reason being that support of
complex models seems to be easier there. Anyway, at this stage I would
like to use CanJS models with Knockout observables.
Is this possible at all? Any issues to take care of?
I have a medium size single page application using Knockout that I would
like to port incrementally to CanJS. The reason being that support of
complex models seems to be easier there. Anyway, at this stage I would
like to use CanJS models with Knockout observables.
Is this possible at all? Any issues to take care of?
How to get content, title,FileAttachment and current location from pdf file
How to get content, title,FileAttachment and current location from pdf file
i am working on PDF annotation app i added PDF file annotation in iPhone
it working fine it annotation also visible any reader but facing one issue
How to get content, title,image and current location from PDF file whose
is created annotation from desktop how can do for this issue
please help me
Thank you in advance
i am working on PDF annotation app i added PDF file annotation in iPhone
it working fine it annotation also visible any reader but facing one issue
How to get content, title,image and current location from PDF file whose
is created annotation from desktop how can do for this issue
please help me
Thank you in advance
Sunday, 1 September 2013
Is there public MS SQL Server with sample databases
Is there public MS SQL Server with sample databases
I study the MYSQL server technologies, and want to try connect to remote
server.
Did anybody knows a public server with sample databases for testing? The
google didn't help me, at the moment.
Thanks!
I study the MYSQL server technologies, and want to try connect to remote
server.
Did anybody knows a public server with sample databases for testing? The
google didn't help me, at the moment.
Thanks!
downloading/scraping 500,000 pages from a website
downloading/scraping 500,000 pages from a website
I need to scrape data from a particular website say example.com.
Now, my interest is in example.com/foo/
Basically, I need to download pages like example.com/foo/xyz-vs-abc.html ,
example.com/foo/def-vs-pqr.html and so on. This will enable me to use all
these pages and process the data in them offline. I have all the links
that I want to download in a csv file.
I am aware that data can be directly extracted from the website itself
without having to download it. But in my case, I think it'd be best if I
have all the pages and then can process them at leisure.
I would also like to know if tool like Scrapy would serve the purpose. I'm
skeptic about it since the number of http requests sent might get me
blocked.
If this is any useful, here is how the robots.txt of my target site looks
like:
User-agent: *
Sitemap: http://www.example.com/sitemap.xml
I need to scrape data from a particular website say example.com.
Now, my interest is in example.com/foo/
Basically, I need to download pages like example.com/foo/xyz-vs-abc.html ,
example.com/foo/def-vs-pqr.html and so on. This will enable me to use all
these pages and process the data in them offline. I have all the links
that I want to download in a csv file.
I am aware that data can be directly extracted from the website itself
without having to download it. But in my case, I think it'd be best if I
have all the pages and then can process them at leisure.
I would also like to know if tool like Scrapy would serve the purpose. I'm
skeptic about it since the number of http requests sent might get me
blocked.
If this is any useful, here is how the robots.txt of my target site looks
like:
User-agent: *
Sitemap: http://www.example.com/sitemap.xml
Subscribe to:
Posts (Atom)