Derby DB is not working on mac.

Hi ! I have developed a Java application using Derby Database. The application jar file is successfully running on Windows but on Mac it gives and exception as following:

  ClassNotFoundException: org.apache.derby.jdbc.EmbeddedDriver

I am pasting code for database Connection which I wrote.

         String dbdriver = "org.apache.derby.jdbc.EmbeddedDriver";
         Class.forName(dbdriver).newInstance();
         con = DriverManager.getConnection("jdbc:derby:C:\\4DSOFTECHDB; create = true"); 

Note: This exception occurs only on Mac OS.

DBMS Login form

so we were trying to make a simple log in form and our professor simply told us to copy the codes he wrote:

ddasdasd.png

i copied it but i got a red line under line 20 and 21 . I dont know what to do, no one is responding to me in the class and my professor never responded when he saw my question. here is the whole code if you cant see it whole in the picture:

ddasdasd.png

How To Create A Star Rating System In WordPress With CSS and ACF

I recently had a request from a WordPress client for a star rating widget of sorts, so I thought I would share the solution I came up with using Advanced Custom Fields (ACF) and CSS. There are no images involved – just pure CSS plus Unicode stars and a handy range slider on the back end so the client can easily enter a rating anywhere from 0 to 5 in steps of 0.1. Thanks to a nice example I found on CodePen (seen below), the front end elements were easy and simple, utilizing CSS custom properties and variables in a compact code. Connecting this to ACF so the client could easily edit their ratings brought it all together in a quick solution that I have not seen elsewhere, thus the idea to make it available here in case anyone else is looking for something similar. Ready to dig in?

UNLIMITED DOWNLOADS: 500,000+ WordPress & Design Assets

Sign up for Envato Elements and get unlimited downloads starting at only $16.50 per month!



Coding The Stars

See the Pen
Tiny but accessible 5 star rating
by Fred Genkin (@FredGenkin)
on CodePen.0

 

As you can see from the above CodePen, there is not much involved, yet it is a cleverly coded idea. This is taken from a great tutorial over on CSS Tricks, called “Five Methods for Five-Star Ratings”. The HTML below utilizes a custom CSS property (--rating) and makes no calls to the server while maintaining accessibility.

<div class="stars" style="--rating: 2.3;" aria-label="Rating of this product is 2.3 out of 5."></div>

The property is actually a conversion from a value to a percentage that’s handled in CSS using the calc() function:

--percent: calc(var(--rating) / 5 * 100%);

Then the filling of the stars based on the rating/percentage is done using a linear-gradient background that creates hard color stops at the percentage points that are designated.

background: linear-gradient(90deg,
  var(--star-background) var(--percent), 
  var(--star-color) var(--percent)
);

In the CodePen example, the author uses CSS variables for the star size, color, and background. You can go this route if you want to be able to change those elements easily, or you can just code them in yourself if you have no plans to change them down the road.

background: linear-gradient(90deg,
  #fc0 var(--percent), 
  #fff var(--percent)
);

Once the stars code is done, we can now make it work with the ACF range slider.

ACF Range Field

I’m assuming you are already familiar with Advanced Custom Fields, since you arrived at this article with it in the title. If not, you can learn more about the plugin here.

For our use case, we want to create a Range field so the client can select a range from 0 to 5 in steps of 0.1, enabling them to set the star rating at 4.7, for example.

In the WordPress backend, navigate to Custom Fields > Add New to create a new field group, then give it a title and click the button labeled Add Field to create the new field. Add the Field Label (we’re using “Stars” in our example), select the Range field type, set the Maximum Value to 5, and the Step Size to 0.1. You can make any other edits you see fit, but these are the minimum to get this working the way we want it to work.

Star Rating field

After saving your changes, you can now edit whatever page, post, or template PHP file in which you want to show the star rating by entering the following code:

<?php
$stars = get_field('stars');
if($stars) echo '<div class="stars" style="--rating: '. $stars .'" aria-label="Rating of this product is '. $stars .' out of 5."></div>';
?>

This code replaces the HTML we were originally using, and now it will show the rating that is set on the backend when the Range field is updated. Pretty simple, right?

Star Rating Range Slider

For reference, here’s the complete CSS that will make the magic happen (derived from the SCSS in the CodePen).

.stars {
    --percent: calc(var(--rating) / 5 * 100%);  
    display: inline-block;
    font-size: 60px;
    font-family: Times; 
    line-height: 1;
}
.stars::before {
    content: '★★★★★';
    letter-spacing: 2px;
    background: -webkit-gradient(linear, left top, right top, from(#fc0), to(#fff));
    background: linear-gradient(90deg, #fc0 var(--percent), #fff var(--percent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

 

How to Split Large XML Files in WordPress (Free Tool)

Is your WordPress export file too large to import into your new website?

WordPress comes with built in import and export functionality that uses the XML file format. Sometimes the exported XML file is larger than your web host’s upload limit.

In this article, we’ll show you how to split large XML files in WordPress.

How to Split Large XML Files in WordPress

Why Split Large XML Files in WordPress?

When moving your blog from WordPress.com to WordPress.org or moving content from a self-hosted WordPress website to a to a new host or server, you will need to export your WordPress content.

WordPress allows you to export your entire WordPress website as a single XML file that contains all of your posts, pages, comments, custom fields, categories, and tags.

This is known as a WXR file and stands for WordPress Extended RSS.

You Can Export Your Website to an XML File

However, sometimes you may find that this file size is larger than the upload limit allowed by your WordPress hosting provider. If the file size is too large, then you will see an error message, and you will not be able to import your website data into the new WordPress installation.

This limit can vary, depending on your hosting provider and plan.

There Is a Limit to the Size of XML File That Can Be Imported

While you can ask your web hosting company to temporarily increase the file size limit, most shared hosting companies will not allow it.

So the only other option you have is to split the XML file into smaller files manually which is hard work.

Luckily, there’s an easy free online tool that can help you automatically split large WordPress XML files.

With that being said, let’s take a look at how to split large XML files in WordPress.

Bonus Free Offer

Need help? Our free WordPress blog setup service can help you migrate from WordPress.com to WordPress.org without any risk. During this guided transfer, one of our expert team members will do the entire migration from WordPress.com for you (100% free).

How to Split Large XML Files in WordPress

Once you have exported your WordPress site to a single XML file, you need to go to the Free WXR File Splitter Tool website. This is a free online tool that is designed to divide a large WordPress export file into small chunks.

Once there, you can upload your XML file by dragging it onto the area labeled ‘Click or drag a file to this area to upload’. Alternatively, you can click the ‘WXR File’ button and then select the XML file.

Upload the XML File to the Free WXR File Splitter Tool

After that, you need to move the ‘New file size’ slider to your website’s maximum upload size or smaller. The goal is to create multiple files that are small enough to be uploaded to your host without surpassing the limits.

When you are ready, you need to press the ‘Submit’ button. Your large XML file will be split into smaller files of the correct size.

Download the Split Files in a Zip File to Your Computer

Finally, you’ll need to press the ‘Download’ button to download the files to the default download location on your computer. The files will be contained in a single file which will need to be unzipped so that you can import them into your new website.

We hope this tutorial helped you learn how to split large XML files in WordPress. You may also want to learn how to create a free business email, or check out our list of the best drag and drop WordPress page builder plugins.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post How to Split Large XML Files in WordPress (Free Tool) first appeared on WPBeginner.

Jamstack Rendering Patterns: The Evolution

In the early days of the Jamstack, developers mostly used it for static sites and opt for a more verbose frontend framework like Vue and React when they need to perform more sophisticated operations like server-side rendering in web applications. The need for adding dynamic functionalities to web apps never went away, but it didn’t make us appreciate Jamstack any less. We loved what it proposed and the value it provided. Web pages are instantly available to users, and developers could build websites easily and deploy them faster. Users are happy, developers are happy; it’s a win-win.

Then came static site generators which made things better by adding a build process to the previous flow of a static site which meant that all the site’s assets were all pre-generated by a build server (not on a local machine) and then deployed. This was a step forward in improving the developer experience of Jamstack developers and consequently the popularity of this model. Developers could build Jamstack sites with a static site generator like Gatsby, push the project to a version control system like Github, and deploy to a hosting service like Netlify which provides a workflow that will rebuild the site when there’s an update to the project.

Everything seemed great, and we were all better for it.

But like every other technology, Jamstack started evolving as the need for more sophisticated functionalities continued to grow. As a “static site”, a Jamstack site was limited in the things it could do, and people did not keep quiet about it. Suddenly, it seemed like Jamstack was an incomplete model that could not be used at scale. The concerns raised were mostly around the inability to perform server-side operations and the length of build times in larger Jamstack sites. This didn’t sit well within the Jamstack community, and we started to “extend” the Jamstack to solve this new challenge, which it was not originally meant to solve.

Dynamic Functionalities In The Jamstack

While Gatsby made a lot of advancements in how we build and update Jamstack sites with features like incremental builds, Next.js introduced server-side rendering with getServerSideProps():

function Page({ data }) {
  // Render data...
}

// This gets called on every request
export async function getServerSideProps() {
  const res = await fetch(`https://.../data`)
  const data = await res.json()

  // Pass data to the page via props
  return { props: { data } }
}

export default Page

While also maintaining the good-old static generation with getStaticProps():

// posts will be populated at build time by getStaticProps()
function Blog({ posts }) {
  return (
    <ul>
      {posts.map((post) => (
        <li>{post.title}</li>))}
    </ul>)
}

export async function getStaticProps() {
  const res = await fetch('https://.../posts')
  const posts = await res.json(
  return {
    props: {
      posts,
    },
  }
}

export default Blog

This gave developers the idea of a hybrid approach to building Jamstack sites. Suddenly, you could build Jamstack sites that could render different pages with different rendering patterns. For instance, your /about page could be statically generated while your /cart page is server-side rendered. However, the issue of long build times remained. But not for long.

With Incremental Static Regeneration (ISR), Next.js also made it possible for pages to be generated on demand and cached for subsequent requests. This meant that developers could have a site with 10,000 pages and only generate 100 pages at build time. All other pages will be dynamically generated on-demand and cached for subsequent requests, effectively bringing the concern about long-running build times to bay.

function Blog({ posts }) {
  return (
    <ul>
      {posts.map((post) => (
        <li key={post.id}>{post.title}</li>))}
    </ul>)
}

export async function getStaticProps() {
  const res = await fetch('https://.../posts')
  const posts = await res.json()

  return {
    props: {
      posts,
    },
    revalidate: 10, // In seconds
  }
}

export async function getStaticPaths() {
  const res = await fetch('https://.../posts', {limit: 100})
  const posts = await res.json()

  // Get the paths we want to pre-render based on posts
  const paths = posts.map((post) => ({
    params: { id: post.id },
  }))

  return { paths, fallback: 'blocking' }
}

export default Blog
Distributed Persistent Rendering (DPR)

In April 2021, Netlify announced a new rendering pattern called Distributed Persistent Rendering. The idea was to remove the revalidation bit of ISR and make any page that is rendered after the initial build a permanent part of that build. No revalidation. If you want to re-render that page in the future, you will need to trigger a new build. According to the announcement post, this pattern will not compromise the Jamstack principle of immutable atomic deploys.

Along with the DPR announcement, Netlify also launched on-demand builders — A special type of serverless function that generates content on-demand, caches it at the edge, and works across all frameworks. This brought ISR-like capabilities to every other static site generator and meta-framework.

const { builder } = require('@netlify/functions');
async function myfunction(event, context) {
   // logic to generate the required content
}

exports.handler = builder(myfunction);

This opened up more opportunities for static site generators like Gatsby to get in on this pattern of delivering web pages with their own adaptation of the concept called Deferred Static Generation (DSG). Eleventy also released the Eleventy Serverless plugin that builds off of the DPR concept to support this rendering pattern for developers.

Deferred Static Generation (DSG)

As mentioned, Gatsby adapted the DPR concept to create a custom DSG rendering pattern that allows developers to defer non-critical pages and only generate necessary content at build time. Like with ISR, the deferred pages are generated on demand and cached. All subsequent requests for those pages are then served from the cache.

// The rest of your page, including imports, page component & page query etc.

export async function config() {
  // Optionally use GraphQL here

  return ({ params }) => {
    return {
      defer: true,
    }
  }
}

The goal of this post is to take a look at the evolution of the Jamstack rendering patterns, where we started, and where we are. At the moment, we’ve come very far from where we started, and for good reason. But personally, I’m thinking, should we have stuck with the initial idea of a Jamstack site? One where we didn’t need to worry about dynamic functionalities. It is 2022, and there’s a lot of nuance around the differences between a Jamstack site and a regular React app.

In Summary

Jamstack has metamorphosed from simply generating and deploying static assets to handling highly dynamic functionalities with advanced rendering patterns and serverless functions.

Yes, there have been advancements in the Jamstack rendering patterns, and it has continued to improve to date. But these improvements consequently added more complexity to an otherwise simple process. In continuing to extend the Jamstack to account for more uses cases, we run the risk of overcomplicating it.

But like in every other space, we expect to see continued improvements. 2021 saw the emergence and dominance of meta frameworks like Astro, Slinkity, and Remix — all trying to ship less JavaScript to the browser.

This seems to be the direction the web is taking in 2022, and we expect to see more solutions come up in the ecosystem to significantly improve the Jamstack experience. The emergence of React Server Components in React, Vite as a faster alternative for Webpack and Babel, Edge computing used by the likes of Remix, HTML Streaming, and so on, are all promising solutions that are continuing to gain popularity and adoption. And we can only surmise that things will get better and more interesting, as these technologies penetrate the existing web infrastructure. Safe to say that the best days of the Jamstack are still ahead of us.

The modern web trending practice for building highly optimized sites is shipping less JavaScript. This is where technologies like Remix claim dominance. It is interesting to watch how the Jamstack space continues to evolve, and I’m personally looking forward to what the next step will be.

If you’re building a Jamstack site today, here are the rendering patterns currently available to you:

  • Static Generation
    Pages are rendered once at build time.
  • Server-Side Rendering
    Pages are generated on a per-request basis.
  • Deferred Rendering (ISR/DPR/DSG)
    Critical pages are generated first at build time, and non-critical pages are generated on demand and cached.

Further Reading on Smashing Magazine