How to use MySQL for .NET Core Azure functions - mysql

I am attempting to write an Azure function and use MySQL but I cannot seem to use the MySQL.Data or MySql.Data.MySqlClient directives. The error I am getting is the following:
The type or namespace name 'MySql' could not be found.
I am not sure what I need to make this work
using MySql.Data;
using MySql.Data.MySqlClient;

This seems to be either Nuget/Project type issue. Try the following,
use NuGet to download the latest version. Just right click on the project and click 'Manage NuGet Packages' then search online for MySql.Data and install.
Check the project or create a new project
To change your project's framework right-click on your project select Properties -> Application -> Target framework.

Related

Package installation error in Yii2 framework?

I have a requirement to use PHPOffice/PhpSpreadsheet, to install PhpSpreadsheet I followed this link.
So I installed PhpSpreadsheet into my project using 'composer' by running the command
composer require phpoffice/phpspreadsheet
at command prompt while installing it said that
Using version dev-master for phpoffice/phpspreadsheet
and was installed successfully(FYI check Screenshot), after installing when I tried to login into my application, I am getting a different error as
Cannot redeclare PHPMailerAutoload()
(previously declared in" for emails I am using 'phpmailer' including the path as
require_once('../vendor/phpmailer/PHPMailerAutoload.php');
as my "PHPMailer" folder resides in 'vendor' folder of Yii2 framework.
By the way I am building my application on Yii2 framework and I am very new to Yii2 framework.
Can anyone please tell, how to fix this? Thanks.
You don't have to use require for packages installed via composer. Yii autoload's feature will take care for that. You just have to write the appropriate use statements in your code. Actually, the mailer is a component declared into the main app, so you don't need the use statement at all
Yii::$app->mailer->compose('/my/mail_view', ['model' => $model])
->setFrom([Yii::$app->params['myMail'] => 'My Name'])
->setTo($model->email)
->setSubject('My subject')
->send();

The type or namespace name 'Http' does not exist in the namespace 'System.Net' in WP8 app

I have this error in downloaded Windows Phone 8 app.
It is declared as
using System.Net.Http;
Seems like it must to work. How to make this work?
It is valid actually you have to install the Nuget package of System.Net.Http.
You can try Enable Nuget Package Restore in the solution. You can
do that by Right Click On Solution => Select Enable Nuget package
restore.
You can also achieve that by go Manage Nuget Packages e.g Project=>
Manage Nuget Packages => Search Online System.Net.Http => Install
the package.
Update Nuget Package :-
Tools=> Extensions and Updates => Updates. then update your Nuget.
Done :)

Nuget, Castle Windsor Client Profile vs Full Profile

I'm trying to use Castle Windsor with Log4Net facility. I've installed the packages through Nuget.
The requirement for this to work is to use Full profile Castle.LoggingFacility. Nuget referenced the Client Profile version.
How can I force Nuget to install the Full profile version?
I might be wrong but it sounds like the issue with the target framework setting on your project:
for Castle.Windsor to work it has to be set to .NET Framework 4 rather than to .NET Framework 4 Client Profile.
You can configure it by opening project properties, tab Application (in Visual studio) or just editing the project file.
If that's about the version of the package after all, then usually using NuGet you can append a flag install-package Castle.Windsor -version 2.5.3 to specify which one to install, but I couldn't find any options there when it comes to Castle.LoggingFacility.
I had the same problem earlier and I think you should check your packages.config file. There could be targetFramework="net40-client",
which points NUGet to the packages\Castle.LoggingFacility.3.2.0\lib\net40-client directory.
Simply change it to net40 and all's done.

Using mysql from Xampp for java jdbc program

I have Xampp installed on my pc with mysql database. now i wish to use this mysql database for my java JDBC program. For that i have writen following program.
package mysqltype4driverdemo;
import java.sql.*;
import java.util.*;
public class MysqlType4DriverDemo {
public static void main(String[] args)throws SQLException {
String url="jdbc:mysql://localhost:3306/mysql";
Properties prop=new Properties();
prop.setProperty("user","root");
prop.setProperty("password","");
Driver d=new com.mysql.jdbc.Driver();
Connection con = d.connect(url,prop);
if(con==null) {
System.out.println("connection failed");
return;
}
DatabaseMetaData dm =con.getMetaData();
String dbversion=dm.getDatabaseProductVersion();
String dbname=dm.getDatabaseProductName();
System.out.println("name:"+dbname);
System.out.println("version:"+dbversion);
}
}
but it says "package com.mysql.jdbc" does not exists.
P.S. : i am using netbeans 7.2.x IDE on windows XP platform
It appears that you might have tried putting the library on the global CLASSPATH. For Netbeans projects, that's not quite right. You need to add the appropriate library(ies) to the project using Netbeans's library facility.
Right-click on the project's root node in the Projects tab.
In the pop-up context menu, click on Properties (on the bottom of the menu).
Click on Libraries under Categories:. You should see the following screen:
Click on the Add Library... button.
Under Global Libraries click on MySQL JDBC Driver and then click the Add Library button.
Click on OK.
You should be good to go.
If you need a specific version of the driver, you can download it, and then after clicking on Add Library... you can click on Create... to add the downloaded version to your library repository. You'd then remove the default JDBC Driver from the project, and add the library containing the specific version.
I tried this out myself using your code and a newly-created project. No additional imports needed, and the default driver included with the Netbeans distro should be good enough unless you need a specific version for your project.
You need to download the JDBC driver for mysql from here.
Once you download it, add the jar to your classpath and you should be good to go.
Alternatively, once you have downloaded the driver, you can paste it in you java installation at ...jre\lib\ext\
Then it would be available for all your projects with the default JRE system library which you can verify when you create a new project.

package javax.ejb does not exist

I have opened a project in netbeans to view the project but there is a same error in most of the files. It says that "package javax.ejb does not exist". This is a working project and I am not sure what is wrong. Can anyone help me?
Try this first: http://forums.netbeans.org/topic44810.html
If that doesn't fix your problem, you can right click on your project and go to the properties section. Click on the Libraries section and select "Add Library". Then scroll down until you find the Libraries that start with "Java" (for example: Java EE 6 API Library). I add all of the Java libraries to my project to resolve this issue, however you might add them one at a time and see which one resolves it.
you just need to import Java EE Web 6 API Library to fix this issue, these libraries must be imported under the libraries folder:
right click Add library, click on import library, scroll down and look for Java EE Web 6 API Library, click on import library and finally click on add library.
That should fix any issues
In my case I was working with java with ant java web app, i was also using Java EE Version Java EE 6 web
I had the same problem when I tried to open a Java web service application and managed to resolve it after trying out a few things. For a Java web service application, there can be multiple causes to the problem. You may have "EJB and EAR" plugin already installed, however, Netbeans may not know the web server to use to run your application. It may have complained that "One or more projects do not have the target server set properly" when the project was opened. To resolve this problem, you have to assign a web server for the project. This is to be done not only for the main project, but also for the required projects that the main project may be dependent upon.
You first need to ensure that you have opened not just the main project, but also the required projects. To open the required projects, right-click on the main projects name in the main projects window and select Open Required Projects -> Open All Projects. After opening, the project names may be colored red in the project window to indicate problem.
In order to use a web server, you need to have one already installed. I chose Glassfish. Download and install Glassfish from https://glassfish.java.net/download.html, if you haven't done so. Also install the "Glassfish Server" plugin for Netbeans, if it's not already installed.
Now, in the Netbeans project window, right-click on the main project name and select "Resolve missing solver issue". If you see "Glassfish server" in the pop-up window that appears, select that one and click ok. If you don't see it, click "Add Server" then select "Glassfish Server", and setup the Glassfish server. Here you need to provide the installation directory of your Glassfish server, but I simply used the default values for the rest. Later I used username "admin" with blank password for running the project. Also perform the same steps to resolve the missing server for all of the required projects.